Html 为什么这些链接没有';我不能改变我的div的高度吗?
链接根本不会改变“支架”的高度,我真的不知道怎么了 HTML:Html 为什么这些链接没有';我不能改变我的div的高度吗?,html,css,Html,Css,链接根本不会改变“支架”的高度,我真的不知道怎么了 HTML: <div id="holder"> <a class="button" href="#"><span>home</span></a> <a class="button" href="#"><span>example</span></a> <a class="button" href="#"><span>
<div id="holder">
<a class="button" href="#"><span>home</span></a>
<a class="button" href="#"><span>example</span></a>
<a class="button" href="#"><span>another examp.</span></a>
<a class="button" href="#"><span>hello</span></a>
<a class="button" href="#"><span>abc</span></a>
</div>
*{
margin:0;
padding:0;
}
#holder{
width:100%;
background: #000;
border: 1px solid red;
}
.button {
color: #444;
display: block;
float: left;
height: 24px;
margin-right: 6px;
padding-right: 18px;
}
.button span {
display: block;
line-height: 14px;
padding: 5px 0 5px 18px;
}
.button:hover {
background: #333 url('./images/bg_button_a.jpg') no-repeat scroll top right;
outline: none;
}
.button:hover span {
background: #333 url('./images/bg_button_span.jpg') no-repeat;
}
这是因为它们是浮动的:左,这样的子元素不会扩展其父元素的维度。 解决这个问题的最简单方法是添加
<div style="clear:both;"></div>
在孩子们的最后。例如:
<div id="holder">
<a class="button" href="#"><span>home</span></a>
<a class="button" href="#"><span>example</span></a>
<a class="button" href="#"><span>another examp.</span></a>
<a class="button" href="#"><span>hello</span></a>
<a class="button" href="#"><span>abc</span></a>
<div style="clear:both;"></div>
</div>
这是因为它们是浮动的:左,这样的子元素不会扩展其父元素的维度。 解决这个问题的最简单方法是添加
<div style="clear:both;"></div>
在孩子们的最后。例如:
<div id="holder">
<a class="button" href="#"><span>home</span></a>
<a class="button" href="#"><span>example</span></a>
<a class="button" href="#"><span>another examp.</span></a>
<a class="button" href="#"><span>hello</span></a>
<a class="button" href="#"><span>abc</span></a>
<div style="clear:both;"></div>
</div>
打开跨度但关闭li可能会导致一些问题
<a class="button" href="#"><span>hello</li></a>
打开跨度但关闭li可能会导致一些问题
<a class="button" href="#"><span>hello</li></a>
浮动元素以不延长其容器的高度。本质上,它们都绑定到容器的顶部(视觉上并非如此)
使用容器底部带有
clear:left
的div将其展开以包含浮动元素。浮动元素不扩展其容器的高度。本质上,它们都绑定到容器的顶部(视觉上并非如此)
使用容器底部带有
clear:left
的div将其展开以包含浮动元素。浮动元素不计入其父元素的高度。设置
溢出:隐藏在#holder
上的code>是一个很好的技巧来纠正这一点。浮动元素不计入其父元素的高度。
设置溢出:隐藏在#holder
上的code>是一个很好的纠正方法。元素不会自动展开以包含浮动的后代
添加是clearfix的一种类型,只要您不介意在元素的边界框处剪切元素,这是最简单的
#holder {
overflow: hidden;
}
.元素不会自动展开以包含浮动的后代
添加是clearfix的一种类型,只要您不介意在元素的边界框处剪切元素,这是最简单的
#holder {
overflow: hidden;
}
.为什么你打开一个span
然后关闭一个li
?哎呀,因为我什么都试过了,(但我可以向你保证这不是问题)为什么你打开一个span
然后关闭一个li
?哎呀,因为我什么都试过了,(但我可以向你保证这不是问题)+1这需要比过多的
+1这需要比过多的
更多的提升。