java如何表格一样对齐_如何水平对齐表格? (How can I horizontally align a form?)

最佳答案

英文原文

remove div tag like this :

中文翻译

删除div标签,如下所示:

<形式>

< input type =" email" placeholder =" example@ravvel.com" >

< input class =" enter" type =" submit" value =" Send" />

< /形式>

remove div tag like this :

删除div标签,如下所示:

<形式>

< input type =" email" placeholder =" example@ravvel.com" >

< input class =" enter" type =" submit" value =" Send" />

< /形式>

参考答案2

Simple way:

More style-ish way:

参考答案3

Get rid of your DIV. You don't need it.

参考答案4

You can add a float: left style to each div that wraps the form elements.

参考答案5

Add the CSS property display with the value inline to the DIV:

#yourdiv

{

display: inline;

}

参考答案6

Well, simply put - if you use float:left on your div elements, it should align them horizontally and get you on your way.

参考答案7

If you want all fields inside a form aligned, you can add display:inline as a CSS rule to the containing elements. I generally like to use paragraph tags to separate each label+input tag, or an un ordered list. To update your example:

form ul {

list-style:none;

}

form li {

display:inline;

}

This will work for each field you add as a new list item.

参考答案8

Input elements are inline-block, meaning they're always on the same line, the reason why you got 2 lines, is because the div element is a block element, in order for it to be able to be aligned with other elements in the same "line", it must be floated, or positioned not relatively.

参考答案9

Strangely, in my case, simply removing 'div' did not help. I have to explicitly put "float:left" to each input in order to get everything in one line. Hopefully it helps someone who falls in the same situation.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值