2015-04-20 62 views
1

我連續顯示五個方形按鈕,並顯示爲一個鎖。但是,當在手機上觀看時,5個圖標不會堆疊,它們會聚集在一起並與其下方的元素重疊。我認爲添加明確的元素將解決,但它不。任何人都可以將我指向正確的方向嗎?Block Element Not Responsive

非常感謝,我非常感謝!

.menu { 
    height: 100px; 
    clear: both; 
    width:100%; 
    margin-bottom:40px; 
    margin-top:35px; 
} 

.icons { 
    height: 100px; 
    width:100px; 
    display: inline-block; 
    margin-left:10px; 
    margin-right:10px; 
    margin-bottom:10px; 
    background-color:#ffffff; 
} 

This is what I am seeing on mobile

+2

問題是不明確......你能給HTML代碼或的jsfiddle? –

+0

作爲一個點clear:both;'將強制'.menu'清除元素邊上的任何東西!你能提供一個例子,你在一個小提琴或類似的工作代碼上面嗎? – Aaron

+0

'清除'只適用於已經浮動的項目......你的項目沒有。 –

回答

0

卸下height財產從.menu類(或者,至少是,將其更改爲min-height)將讓您的父元素的高度擴展,以適應其內容,從而推動內容它在頁面之後。

請參閱下面的示例以獲得舉例說明。

div{ 
 
    background:green; 
 
    margin:5px 0; 
 
    padding:5px; 
 
} 
 
p{ 
 
    font-family:sans-serif; 
 
    margin:0; 
 
} 
 
div p{ 
 
    background:red; 
 
    min-height:40px; 
 
} 
 
div~div{ 
 
    height:20px; 
 
}
<div> 
 
    <p>This paragraph's parent doesn't have set height and therefore will expand to fit the height of this paragraph</p> 
 
</div> 
 
<p>This is just a placeholder</p> 
 
<div> 
 
    <p>This paragraph's parent has a set height and therefore won't expand to fit the height of this paragraph</p> 
 
</div> 
 
<p>This is just a placeholder</p>

+0

非常感謝你@Shaggy,解決了這個問題! –

+0

不客氣。感謝接受。 – Shaggy