我有两个
<fieldset>
在一个单独的里(没有其他内容),它们彼此相邻(position: absolute,div设置为relative)。
有没有办法使这些
有没有办法使这些
我有点晚了,但你总可以使用表格(虽然我也不喜欢表格,但在这种情况下表格是可行的)。
<table>
<tr>
<td style="vertical-align:top">
<fieldset></fieldset>
</td>
<td style="vertical-align:top">
<fieldset></fieldset>
</td>
</tr>
</table>
height=100%
。height=59px
,或者可以通过 JavaScript 完成。vertical-align:center
。以下方法不需要使用js/jQuery,但是依赖于-在这个例子中-使用css3伪元素 :nth-of-type(odd)
,不过这也可以通过为奇数个fieldset应用css类来替换。
它还依赖于对fieldset
使用height: 100%
,这本身取决于父元素(在这种情况下是form
)有一个指定的高度。如果那是一个问题,那么为了演示目的,我已经在fieldset上使用了overflow-y: auto;
将它们的尺寸限制在其父元素的尺寸内,但具有滚动行为以显示溢出内容。
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title></title>
<link rel="stylesheet" type="text/css" href="http://davidrhysthomas.co.uk/mindez/css/stylesheet.css" />
<style type="text/css" media="all">
form {
width: 50%;
height: 200px;
}
fieldset {
width: 30%;
height: 100%;
margin: 0 1em 0 0;
padding: 0.5em 1em;
overflow-y: auto;
}
fieldset:nth-of-type(odd)
{
float: left;
}
label {
display: inline-block;
width: 30%;
}
input[type=text]
{
display: inline-block;
width: 50%;
}
</style>
</head>
<body>
<div id="wrap">
<form enctype="form/multipart" method="post" action="">
<fieldset>
<label for="one">Label 1</label><input id="one" name="one" type="text" />
<label for="two">Label 2</label><input id="two" name="two" type="text" />
</fieldset>
<fieldset>
<label for="three">Label 3</label><input id="three" name="three" type="text" />
<label for="four">Label 4</label><input id="four" name="four" type="text" />
<label for="five">Label 5</label><input id="five" name="five" type="text" />
<label for="six">Label 6</label><input id="six" name="six" type="text" />
</fieldset>
</form>
</div>
</body>
</html>
在线演示地址:http://www.davidrhysthomas.co.uk/so/fieldsets.html。
如果您有任何问题或问题,请随时在评论中提出,我会尽力帮助您。 =)