[英]Auto height of parent div where child divs have skewed edges
I was working on a little something for myself and I walked into a problem i simply cant solve. 我正在为自己做一些事情,但遇到一个我根本无法解决的问题。 I am trying to achieve a small effect where there are 2 divs with skewed edges.
我正在尝试在边缘偏斜的2个div上实现较小的效果。 However, their parent div gets a scrollbar because the skew falls outside.
但是,其父div会获得一个滚动条,因为偏斜不在外面。
HTML HTML
<div class="c-r">
<div class=" c-c c-r-l-1">
</div>
<div class="c-c c-r-r-1">
</div>
</div>
CSS CSS
.c-r{
display: block;
height: auto;
overflow: auto;
}
.c-c{
width: 50%;
height: 300px;
margin-top: 150px;
position: relative;
display: inline-block;
float: left;
background: #44bf86;
}
.c-r-l-1:before, .c-r-l-1:after {
content: '';
width: 100%;
height: inherit;
position: absolute;
background: inherit;
z-index: -1;
transition: ease all .5s;
-webkit-transform:skewY(5deg) ;
-moz-transform: skewY(5deg);
-ms-transform: skewY(5deg);
-o-transform:skewY(5deg) ;
transform:skewY(5deg) ;
}
.c-r-l-1:before {
top: 0;
z-index: 12;
transform-origin: right top;
}
.c-r-l-1:after {
bottom: 0;
z-index: 12;
transform-origin: left bottom;
}
.c-r-r-1:before, .c-r-r-1:after {
content: '';
width: 100%;
height: inherit;
position: absolute;
background: inherit;
z-index: -1;
transition: ease all .5s;
}
.c-r-r-1:before {
top: 0;
transform-origin: left top;
transform: skewY(-5deg);
}
.c-r-r-1:after {
bottom: 0;
transform-origin: right bottom;
transform: skewY(-5deg);
}
@media screen and (max-width: 720px){
.c-r{
display: block;
overflow: auto;
}
.c-c{
width: 100%;
}
}
I am not really sure what other info I can give you than this. 除此以外,我还不确定我还能提供什么其他信息。 I hope you all can help me out and thank you for taking your time.
希望大家能帮助我,感谢您抽出宝贵的时间。
~Greetings 〜问候
I found the fix to my problem. 我找到了解决问题的方法。
All i had to do was add: 我要做的就是添加:
padding-top: 5%;
padding-bottom: 5%;
The reason why it has to be 5 is because my skew is going 5 degrees! 之所以必须为5,是因为我的偏斜要达到5度!
To my outer div. 到我的外部div。 everything works fine now.
现在一切正常。 Thanks everyone for their time!
感谢大家的宝贵时间!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.