2016-08-08 52 views
-1

我正在製作新聞通訊,所以我必須製作2列,並使用2個div來做width的50%。 但問題是,右側的div超出內容。Div以上內容?

我該如何解決這個問題?感謝的

這裏是fiddle

#yellow { 
 
    background-color: rgb(214, 196, 0); 
 
    width: 100%; 
 
    margin-bottom: auto; 
 
} 
 
#yellowL { 
 
    float: left; 
 
    width: 50%; 
 
} 
 
#yellowR { 
 
    position: relative; 
 
    float: right; 
 
    width: 50%; 
 
} 
 
#h1v2 { 
 
    color: rgb(67, 153, 186); 
 
    background-color: rgb(214, 196, 0); 
 
}
<div id="yellow"> 
 
    <h1 id="h1v2">Geschäftsverlauf/Déroulement des affaires</h1> 
 
    <div id="yellowL"> 
 
    <h1 id="h1v2">Offerten</h1> 
 
    <p> 
 

 
    </p> 
 
    <h1 id="h1v2">Projekte</h1> 
 
    <p> 
 

 
    </p> 
 
    </div> 
 
    <div id="yellowR"> 
 
    <h1 id="h1v2">Offres</h1> 
 
    <h2>Bruit</h2> 
 
    <p> 
 

 
    </p> 
 
    <h2>Sols</h2> 
 
    <p> 
 

 
    </p> 
 
    <h2>Déchets</h2> 
 
    <p> 
 

 
    </p> 
 
    <h2>EIE</h2> 
 
    <p> 
 

 
    </p> 
 
    <h2>Physique et acoustique du bâtiment</h2> 
 
    <p> 
 

 
    </p> 
 
    <h1 id="h1v2">Projets</h1> 
 
    <h2>Bruit</h2> 
 
    <p> 
 

 
    </p> 
 
    </div> 
 
</div>

+0

https://jsfiddle.net/v1ktxL36/7/#&togetherjs=dMjuryFAOl – Miguel

+1

編輯問題並加入[MCVE]。不要僅僅鏈接到評論中的第三方代碼。 – Quentin

+1

重點詞**最小** –

回答

0

添加overflow: hidden;#yellow CSS規則

#yellow { 
    background-color: rgb(214, 196, 0); 
    width: 100%; 
    margin: auto; 
    overflow:hidden; 
} 
+0

謝謝你的傢伙,這是完美的 – Miguel

0

您可以將此行添加到div這兩個後到來:

#personnel { 
    clear: both; 
} 

我在小提琴中編輯了你的代碼。 這將使所有上面的內容在這個新的div開始之前完成。