【发布时间】:2012-11-04 22:24:04
【问题描述】:
我需要用他最左边的孩子(三个孩子中的)填充<LI> 宽度元素。这三个孩子的格式是display: inline-block; float: right。
到目前为止我所取得的成就:
我期望达到的目标:
显然width: 66% 无论如何也帮不上忙。 100% 的宽度也不起作用。
我在 stackoverflow 上找到了这个 question,但我需要用纯 CSS 制作的东西,没有 JS、jQuery 等。另外,使用表格对我来说不是一个解决方案。
如果 HTML 代码可以帮助解决这个问题:
<style type="text/css">
div {
width: 200px;
border: 1px solid red;
}
ul {
padding: 0px 0px 0px 20px;
margin: 0px;
}
li {
display: block;
white-space: nowrap;
list-style-type: none;
display: block;
height: 20px;
padding: 0px;
margin: 1px;
-moz-border-radius: 3px;
-webkit-border-radius: 3px;
border-radius: 3px;
border-color: #D5AB55 #C93 #C93 #D5AB55;
background-color: #F3CE00;
}
.name {
display: inline-block;
float: right;
height: 18px;
width: 65%;
margin: 0px;
padding: 0px 2px;
border: 1px solid grey;
-moz-border-radius: 3px;
-webkit-border-radius: 3px;
border-radius: 3px;
}
.save, .cancel {
display: inline-block;
float: right;
height: 20px;
width: 20px;
margin: 0px 0px 0px 1px;
padding: 0px;
border: 1px solid grey;
-moz-border-radius: 3px;
-webkit-border-radius: 3px;
border-radius: 3px;
}
.save { background: url(../images/confirm.png) no-repeat center center; }
.cancel { background: url(../images/cancel.png) no-repeat center center; }
</style>
<div>
<ul>
<li>
<input type="button" value="" class="cancel">
<input type="button" value="" class="save">
<input type="text" value="Big list item" class="name">
</li>
<ul>
<li id="category_2" id_category="2">
<input type="button" value="" class="cancel">
<input type="button" value="" class="save">
<input type="text" value="Medium list item" class="name">
</li>
<ul>
<li>
<input type="button" value="" class="cancel">
<input type="button" value="" class="save">
<input type="text" value="1st small item" class="name">
</li>
<li>
<input type="button" value="" class="cancel">
<input type="button" value="" class="save">
<input type="text" value="2nd small item" class="name">
</li>
<li>
<input type="button" value="" class="cancel">
<input type="button" value="" class="save">
<input type="text" value="3rd small item" class="name">
</li>
</ul>
</ul>
</ul>
</div>
感谢您的宝贵时间,
同步,
【问题讨论】:
-
您意识到您的 HTML 无效,对吧?
ul(或ol)的唯一有效子元素是li元素:将ul直接嵌套在另一个ul中不是有效的HTML(它们需要包含在父li标记中)。
标签: html css fill-parent