我有兩個height: 100%;
框在另一個div內。但是當我製作內部框height: 100%;
時,綠色<h2>
正在紅色框中移動。我怎麼解決這個問題?溢出CSS高度:100%?
代碼:http://jsfiddle.net/ajnglagla/9yL7c946/
我有兩個height: 100%;
框在另一個div內。但是當我製作內部框height: 100%;
時,綠色<h2>
正在紅色框中移動。我怎麼解決這個問題?溢出CSS高度:100%?
代碼:http://jsfiddle.net/ajnglagla/9yL7c946/
我有最好的解決方案。試試這個
.a-detay section {
margin: 0 0 30px 0;
}
.a-detay section h2 {
font-size: 190%;
font-weight: normal;
line-height: 1.15em;
margin: 10px 0;
}
.a-detay section .k-konteyner {
position: relative;
}
.a-detay section .k-konteyner .alanozet {
padding: 10px;
width: 134px;
height: 100%;
position: absolute;
right: 0px;
box-sizing: border-box;
top: 0;
}
.a-detay section .k-konteyner .detay {
padding: 30px;
width: 100px;
}
.a-detay #guvenlik .k-konteyner {
border: 5px solid #f7464a;
}
.a-detay #guvenlik .k-konteyner .alanozet {
background-color: #f7464a;
}
.a-detay #guvenlik h2 {
color: #f7464a;
}
.a-detay #saglik .k-konteyner {
border: 5px solid #4eb055;
}
.a-detay #saglik .k-konteyner .alanozet {
background-color: #4eb055;
}
.a-detay #saglik h2 {
color: #4eb055;
}
<section class="a-detay">
<section id="guvenlik" class="konu">
<h2>Red</h2>
<div class="k-konteyner">
<div class="detay">
Left
<br>Left
<br>Left
<br>Left
<br>Left
<br>Left
</div>
<div class="alanozet">When i make this area height 100%, Green H2 is being over the RED box.</div>
</div>
</section>
<section id="saglik" class="konu">
<h2>Green</h2>
<div class="k-konteyner">
<div class="detay">
Left
<br>Left
<br>Left
<br>Left
<br>Left
<br>Left
</div>
<div class="alanozet">When i make this area height 100%, Green H2 is being over the RED box.</div>
</div>
</section>
</section>
Wowww非常感謝你:)它的作品很棒:)謝謝。 – Gulhan 2014-09-25 09:22:36
你可以檢查這個嗎? http://imgur.com/ZmGw20N它看起來不錯,但當我在螢火蟲的綠色部分,它顯示突出顯示的區域仍然在紅色框。如果我在紅色部分顯示,就像那樣http://imgur.com/0RGDdhr – Gulhan 2014-09-24 11:19:34
我會查找它。不掛斷。 – 2014-09-24 11:20:38
對不起,不知道,但我看到你使用了很多不必要的'浮動' – 2014-09-24 11:32:17
試試這個
html,
body {
height: 100%;
}
.a-detay {
float: left;
width: 100%;
height: 100%;
}
.a-detay section {
width: 100%;
height: 100%;
box-sizing: border-box;
margin: 0 0 30px 0;
}
.a-detay section h2 {
font-size: 190%;
font-weight: normal;
line-height: 1.15em;
margin: 10px 0;
}
.a-detay section .k-konteyner {
float: left;
width: 100%;
height: 100%;
box-sizing: border-box;
}
.a-detay section .k-konteyner .alanozet {
float: right;
padding: 0 0 20px 0;
width: 134px;
height: 100%;
box-sizing: border-box;
}
.a-detay section .k-konteyner .detay {
float: left;
padding: 30px;
width: 200px;
}
.a-detay #guvenlik .k-konteyner {
border: 5px solid #f7464a;
}
.a-detay #guvenlik .k-konteyner .alanozet {
background-color: #f7464a;
}
.a-detay #guvenlik h2 {
color: #f7464a;
}
.a-detay #saglik .k-konteyner {
border: 5px solid #4eb055;
}
.a-detay #saglik .k-konteyner .alanozet {
background-color: #4eb055;
}
.a-detay #saglik h2 {
color: #4eb055;
}
<section class="a-detay">
<section id="guvenlik" class="konu">
<h2>Red</h2>
<div class="k-konteyner">
<div class="detay">
Left
<br>Left
<br>Left
<br>Left
<br>Left
<br>Left
</div>
<div class="alanozet">
When i make this area height 100%, Green H2 is being over the RED box.
</div>
</div>
</section>
<section id="saglik" class="konu">
<h2>Green</h2>
<div class="k-konteyner">
<div class="detay">
Left
<br>Left
<br>Left
<br>Left
<br>Left
<br>Left
</div>
<div class="alanozet">
When i make this area height 100%, Green H2 is being over the RED box.
</div>
</div>
</section>
</section>
.a-detay #saglik h2 {margin-top:30px;color:#4eb055;}
修改這樣的CSS規則。這將工作我想..但我不知道該方法的正確與否
或本
.a-detay section { float:left; width:100%; height:100%; box-sizing: border-box; margin:30px 0px 30px 0;}
它看起來不錯,但是當我將鼠標移過去時,我仍然看到hightlighted區域沒有超過div – Gulhan 2014-09-25 07:10:30
嗯,這是溢究竟是如何':hidden'是_supposed_工作 - 你得到的是100%的高的元素,如果其含量超過高度,它只是_overflows_元素,不再次影響其有效高度。如果你不想這樣做 - 那就不要使用'overflow:hidden' ......也許你只是想指定一個最小高度而不是......? – CBroe 2014-09-24 11:01:39
我嘗試過溢出:隱藏,但這並不能解決我的問題。我有6個不同的高度div盒。我寫了一個小jQuery給他們不同的高度,但我希望用純css解決這個問題@CBroe – Gulhan 2014-09-25 08:32:46