English 中文(简体)
IE7 中选择性清除浮点项目
原标题:selective clearing float items in IE7

I have a list of 5 items which are floated left, and displayed inline. on the 4rd item, I set clear left, thereby causing the 4th item into a new line.

但是在 IE7 中, 第5项在第一行的第3项旁边浮动, 而不是在新行的第4项旁边浮动。 如何让这个为 IE7 工作?

jsfidd.net/3dSSSP/4/

最佳回答

我见过很多次了 不幸的是 我所知道的唯一解决办法 就是有一个分离的清空元素来清除浮标

丑陋却有效:

<ul>
  <li>List 1</li>
  <li>List 2</li>
  <li>List 3</li>
  <li class="clear">&nbsp;</li>
  <li>List 4</li>
  <li>List 5</li>
</ul>

CSS :

.clear{
  display: block;
  float: none;
  clear: both;
  height: 1px;
  line-height: 1px;
  font-size: 1px;
}

字体声明将确保清除 div 的像素只有1 个高, 否则它将会是当前字体大小( yay!) 的高度 。

由于这只是IE7, 我将保持您的标记清除, 并在此额外加插动态的 Javascript, 用于 just & lt; IE8 。

问题回答

暂无回答




相关问题
Image rendered with wrong colors in IE8

I have a gradient image as a PNG (no transparency) in a web-page. By taking a screenshot of Chrome showing the page and cropping the image from the page, I see the exact same colors are drawn as the ...

Determine Mobile Internet Explorer version

I need to determine the version of Mobile Internet Explorer on a Windows Mobile 6.1 device. So that I can report the same user-agent string as is being used by Mobile Internet Explorer. The user-...

CSS working only in Firefox

I am trying to create a search text-field like on the Apple website. The HTML looks like this: <div class="frm-search"> <div> <input class="btn" type="image" src="http://www....

Internet Explorer only part loading JavaScript/CSS

I m having trouble with my local development environment where IE (6 through to 8) is only part loading JavaScript/CSS files. It throws random errors at random places in jquery.min.js every time I ...

IE doesn t run Javascript when you click back button

I ve built a shop with tons of JS running. One of the pieces of the cart, is a zip code field which is required to calculate shipping cost. This works fine going through the cart. Now clicking ...

热门标签