【发布时间】:2012-10-10 06:00:16
【问题描述】:
我在 IE9 中遇到了一个跨度 (span.share) 的问题,我试图在一个跨度为 float:left 的 div 旁边使用 float:right。所有这些都在一个跨度内。
jsfiddle(记得在IE中查看):http://jsfiddle.net/MgW6R/2/
这是它在 IE9 中的样子:
这就是它的外观(和在其他浏览器中的外观):
html
<div class="contentWrapper">
<div class="content">
<span class="contentItem">
<a href="javascript: void(0);">
<img src="http://www.example.com/image1.jpg">
</a>
<div class="detailsWrapper">
<div class="name-date">
<span class="date">Jul 04: </span>
<span class="userName">Christie</span>
</div>
<span class="share"></span>
<div class="clear"></div>
<div class="caption">Watching the fireworks in NY without the crowds, heat and concussion via tv #cahs</div>
</div>
</span>
<span class="contentItem">
...
</span>
</div>
</div>
css
.contentWrapper {
overflow: hidden;
position: relative;
}
.content {
margin-left: 256px;
padding-top: 14px;
position: relative;
white-space: nowrap;
}
.contentItem {
display: inline-block !important;
margin: 0 14px 0 0;
vertical-align: top;
}
.contentItem a {
display: block;
}
.contentItem img {
height: 450px;
}
.contentItem .detailsWrapper {
color: #E3E3E3;
position: relative;
}
.contentItem .detailsWrapper .name-date {
float: left;
padding: 5px 0 0;
}
.contentItem .detailsWrapper .share {
background: url("http://www.connectionsacademy.com/_images/teenWebsite/share-btn-sprite.png") no-repeat scroll 0 0 transparent;
cursor: pointer;
float: right;
height: 23px;
width: 91px;
}
.clear { clear: both; }
.contentItem .detailsWrapper .caption {
margin-top: 10px;
white-space: normal;
width: 450px;
word-wrap: break-word;
}
注意:
我最初有 span.share position:absolute 但我不得不更改它,因为它会导致页面上的其他元素出现问题。
【问题讨论】:
-
我不得不问,你为什么要在
span.contentItems 中设置display:block,但是你在CSS 中却有display:inline-block !important;用于同一个项目...? -
@Kolink 这个页面上有很多 jquery,在那个元素上设置了 jquery
display:block。我已经证实这不是 ie 中的问题。 -
如果您指的是
.name-date,请将其位置与标记上的span.share交换。 -
@bfavaretto
.name-date应该是float:left和.share应该是float:right -
@bfavaretto 切换 html 中的元素没有区别
标签: html css internet-explorer css-float