[英]IE7 not respecting display: block on <ul> <li> <a>
I am attempting a simple vertical navigation using the following HTML markup: 我正在尝试使用以下HTML标记进行简单的垂直导航:
<ul>
<li><a></a></li>
<li><a></a></li>
<li><a></a></li>
</ul>
Despite having display: block;
尽管有
display: block;
on both the <li>
and <a>
elements, IE7 does not appear to respect the full width of the containing div. 在
<li>
和<a>
元素上,IE7似乎不尊重包含div的整个宽度。 Any ideas on this one? 关于这个的任何想法?
http://jsfiddle.net/6eKGL/ http://jsfiddle.net/6eKGL/
UPDATE UPDATE
I now believe the issue is related to the position
property of the container div and the fact that its width is to be determined by the content inside of the <a>
elements. 我现在相信这个问题与容器div的
position
属性以及它的宽度由<a>
元素内部的内容决定的事实有关。
Here is the updated fiddle with IE-7 issue solved. 以下是解决IE-7问题的更新小提琴。 http://jsfiddle.net/6eKGL/35/
http://jsfiddle.net/6eKGL/35/
Demo: http://jsfiddle.net/6eKGL/35/embedded/result 演示: http : //jsfiddle.net/6eKGL/35/embedded/result
CSS: CSS:
#ajax-search ul li a {
display: block;
/*min-width: 150px;*/ // Remove this rule and the IE-7 will start respecting the display block
padding: 9px 18px;
}
See below screenshot of IE-7 请参见下面的IE-7截图
设置overflow: hidden
在<li>
元素上为我做的伎俩!
try adding a doctype to your html, preferrably html5 or xhtml 1.0 strict. 尝试在你的html中添加一个doctype,最好是html5或xhtml 1.0 strict。 that way, IE7 renders in standards mode and not use it's own box model.
这样,IE7以标准模式呈现,而不是使用它自己的盒子模型。
also, use a css reset. 另外,使用css重置。 google for "eric meyer reset".
谷歌为“埃里克梅耶重置”。
references: 引用:
http://www.quirksmode.org/css/quirksmode.html http://www.quirksmode.org/css/quirksmode.html
http://meyerweb.com/eric/thoughts/2007/05/01/reset-reloaded/ http://meyerweb.com/eric/thoughts/2007/05/01/reset-reloaded/
http://en.wikipedia.org/wiki/Quirks_mode http://en.wikipedia.org/wiki/Quirks_mode
UPDATE: 更新:
see this fiddle: http://jsfiddle.net/6eKGL/23/ 看到这个小提琴: http : //jsfiddle.net/6eKGL/23/
设置overflow:hidden
了UL和一些宽幅的 http://jsfiddle.net/sergeir82/N2thx/
从“#ajax-search ul li a {display:block; padding:9px 18px; min-width:150px;}”中删除“min-width”后尝试
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.