开发者

How to get align a form like table using div?

开发者 https://www.devze.com 2023-01-30 21:39 出处:网络
Here is my code: <div> <label>Name</label><input type=\"text\" id=\'name\'/><br />

Here is my code:

<div>
    <label>Name</label><input type="text" id='name'/><br />
    <label>Email</label><input type="text" id='email'/><br />
    <label>Place</label><input type="text" id='place'/><br />
</div>

I'm new to CSS, I don't want table to get aligned, but the perfection should开发者_高级运维 be like same, and don't want to apply style to individual elements. Any help is appreciated.


I'm assuming you want to align the labels and inputs next to one another, in which case you'll be needing floats. Here's the quick css code:

form {
 width: 500px;
 overflow:hidden;}

label {
 clear: both;
 float: left;
 width: 40%;}

input {
 float: left;
 width: 55%;}

I think that should work :)

0

精彩评论

暂无评论...
验证码 换一张
取 消