gpt4 book ai didi

css - 为什么我的元素只适用于向右浮动(而不是向左浮动)

转载 作者:行者123 更新时间:2023-11-28 13:29:58 25 4
gpt4 key购买 nike

如果我将 firstGroup 设置为 float: right,我会得到两列,第一组按预期在右边。但是,如果我将它设置为 float: left,我只会让以下元素卡在第一个元素的底部!

注意:我需要一直支持 IE7,所以没有 column-count

这是我的页面的一个大大简化的版本(我只留下了相关的 block 元素并且只给出了一些示例元素):

<!DOCTYPE html>
<html>
<head>
<title>Take</title>
<style type="text/css">
.group
{
margin-bottom: 20px;
width: 50%;
min-width: 530px;
}

.group > .group
{
margin-bottom: 0px;
}

.group > .label
{
display: block;
width: 510px;
padding: 5px;
border: 1px solid black;
}

.firstGroup
{
float: left;
}

.item
{
display: block;
width: 510px;
padding: 5px;
border: 1px solid black;
}

.item .label
{
display: block;
float: left;
width: 200px;
height: 20px;
}

.header textarea
{
display: block;
}

.header
{
margin-bottom: 20px;
}
</style>
</head>
<body>
<div class="page">
<div class="main">
<h2>Title</h2>
<form>
<div class="header">
Notes :
<textarea name="Notes"></textarea>
</div>
<div class="group firstGroup">
<span class="label" style="background-color: #005588; color: white;">List 1</span>
<div class="group">
<span class="label" style="background-color: #999999; color: #000000;">Sub List 1</span>

<span class="item" style="background-color: #339933; color: #000000;">
<span class="label">Item 1</span>
<span class="options">
<span class="option"><input name="item[0].itemResultID" type="radio" value="0" checked="checked" />N/A</span>
<span class="option"><input name="item[0].itemResultID" type="radio" value="1" />Yes</span>
<span class="option"><input name="item[0].itemResultID" type="radio" value="2" />No</span>
</span>
<span class="notes"><input type="text" name="item[0].TestNotes" value="" /></span>
</span>

<span class="item" style="background-color: #339933; color: #000000;">
<span class="label">Item 2</span>
<span class="options">
<span class="option"><input name="item[1].itemResultID" type="radio" value="0" checked="checked" />N/A</span>
<span class="option"><input name="item[1].itemResultID" type="radio" value="1" />Yes</span>
<span class="option"><input name="item[1].itemResultID" type="radio" value="2" />No</span>
</span>
<span class="notes"><input type="text" name="item[1].TestNotes" value="" /></span>
</span>

<span class="item" style="background-color: #339933; color: #000000;">
<span class="label">Item 3</span>
<span class="options">
<span class="option"><input name="item[2].itemResultID" type="radio" value="0" checked="checked" />N/A</span>
<span class="option"><input name="item[2].itemResultID" type="radio" value="1" />Yes</span>
<span class="option"><input name="item[2].itemResultID" type="radio" value="2" />No</span>
</span>
<span class="notes"><input type="text" name="item[2].TestNotes" value="" /></span>
</span>
</div>
<div class="group">
<span class="label" style="background-color: #999999; color: #000000;">Sub List 2</span>

<span class="item" style="background-color: yellow; color: #000000;">
<span class="label">Item 1</span>
<span class="options">
<span class="option"><input name="item[3].itemResultID" type="radio" value="0" checked="checked" />N/A</span>
<span class="option"><input name="item[3].itemResultID" type="radio" value="1" />Yes</span>
<span class="option"><input name="item[3].itemResultID" type="radio" value="2" />No</span>
</span>
<span class="notes"><input type="text" name="item[3].TestNotes" value="" /></span>
</span>
</div>
</div>
<div class="group">
<span class="label" style="background-color: red; color: white;">List 2</span>

<span class="item" style="background-color: #339933; color: #000000;">
<span class="label">Item 1</span>
<span class="options">
<span class="option"><input name="item[4].itemResultID" type="radio" value="0" checked="checked" />N/A</span>
<span class="option"><input name="item[4].itemResultID" type="radio" value="1" />Yes</span>
<span class="option"><input name="item[4].itemResultID" type="radio" value="2" />No</span>
</span>
<span class="notes"><input type="text" name="item[4].TestNotes" value="" /></span>
</span>

<span class="item" style="background-color: #339933; color: #000000;">
<span class="label">Item 2</span>
<span class="options">
<span class="option"><input name="item[5].itemResultID" type="radio" value="0" checked="checked" />N/A</span>
<span class="option"><input name="item[5].itemResultID" type="radio" value="1" />Yes</span>
<span class="option"><input name="item[5].itemResultID" type="radio" value="2" />No</span>
</span>
<span class="notes"><input type="text" name="item[5].TestNotes" value="" /></span>
</span>
</div>
<input type="submit" value="Submit" />
</form>
</div>
</div>
</body>
</html>

我在 FF 8 和 IE 9 中测试过,两者的行为相同。

最佳答案

你应该 float .group 而不仅仅是 .firstGroup

关于css - 为什么我的元素只适用于向右浮动(而不是向左浮动),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13681851/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com