2013-11-14 33 views
0

我有两个问题,但第二个问题不能解决,直到第一个问题得到解决。该页面正在按预期工作,但是当我开始工作并开始在页面上工作时,该页面似乎已被打破。我在两个位置使用相同的浏览器。Div不包括图像属性

问题是div的背景设置为auto,就像我在同一页面上的所有其他div一样,但由于某种原因,最后一个div没有跨越到图像的底部。 http://i.imgur.com/9DJa3Fp.png?1

<div class="items"> 

<h2><a name="friday"><a href="#">Friday catch of the day:</a></a></h2> 

    <img src="images/catch.png" align="right" alt="Sage-rubbed Double-cut Pork Chop" /> 

    <p><span class="title">Alaskan Halibut with a Rich Loire Valley Beurre Blanc Sauce</span> - served with mashed purple Peruvian potatoes and haricot verts.</p> 

    <p><span class="title">Recommended pairing:</span> '98 Passi Emilio Vineyards Sauvignon Blanc</p> 


</div> 

CSS

.items { 
    margin: 20px; 
    height: auto; 
    width: 910px; 
    background-color: rgba(0, 0, 0, .7); 
    padding: 10px; 
    z-index: 1; 
} 
.items img { 
    float: left; 
    margin-right: 10px; 
    float: right; 
    border-radius: 6px; 
    width: auto; 
    padding: 8px; 
    background-color: #FFFFFF; 
} 
.items p { 
    font-family: 'PT Sans'; 
    font-size: 16px;  
} 
.items a { 
    color: #FFFFFF; 
    text-decoration: none;  
} 

回答

0
.items img { 
    float: left; <---- ??? 
    margin-right: 10px; 
    float: right; <---- ??? 
    border-radius: 6px; 
    width: auto; 
    padding: 8px; 
    background-color: #FFFFFF; 
} 

你浮离开。选择一个。之后您还需要清除浮标以恢复正常流程

+0

我怎么错过了?谢谢!另外,当你说清理我的花车,你的意思是使用

,并设置清除? –

+0

这将做到这一点。 –

0

overflow: auto添加到项目类别。

.items { 
    margin: 20px; 
    height: auto; 
    width: 910px; 
    background-color: rgba(0, 0, 0, .7); 
    padding: 10px; 
    z-index: 1; 
    overflow: auto; 
} 
0

一种解决方案可能是添加一个空的divclear: both

HTML:

<div class="items"> 
    ...  
    <div class="clear"></div> 
</div> 

CSS:

.clear { 
    clear: both; 
} 

JSFiddle

0

在这里,你走了。将此代码保存为任何未来开发的代码片段。只要将父类的.clearfix添加到父容器中(如果它包含浮动子元素,那么你就很好:))

.clearfix{*zoom:1;} 
.clearfix:before,.clearfix:after{display:table;content:"";line-height:0;} 
.clearfix:after{clear:both;}