我有两个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