[英]Parent rounded corners overlap with child
I am stuck with a problem, I have a nav
and in it i got two div
and in those I got one li
each. 我陷入了一个问题,我有一个nav
,在其中有两个div
,在其中每个都有一个li
。 I want the div
s to overlap the nav
bar but what is making me stuck is that I want the nav
bar to get rounded corners where the div
overlaps it means that the div
s need to stretch out their corners to make a rounded form for the nav
bar. 我希望div
重叠nav
栏,但是让我陷入困境的是,我希望nav
栏在div
重叠的地方获得圆角,这意味着div
需要伸出自己的角以形成圆形nav
栏。 Is that possible and how could I do that? 那有可能吗,我该怎么做?
ul { list-style: none; } div { display: inline-block; width: 20%; height: 30px; margin: 0; position: relative; text-align: center; -webkit-transform: skew(-40deg); -moz-transform: skew(-40deg); -o-transform: skew(-40deg); background-color: #ddd; } nav { background-color: #777; padding: 0; } li { font-size: 0.8em; position: relative; top: 505; margin-top: -0.4em; -webkit-transform: skew(40deg); -moz-transform: skew(40deg); -o-transform: skew(40deg); }
<nav> <ul> <div class="overlapping_div"> <li>Text in div</li> </div> <div class="overlapping_div"> <li>Text in div</li> </div> </ul> </nav>
li needs to be the direct child of a ul, in order to do what you want maybe try this solution: li需要成为ul的直系子孙,以便执行您想要的操作,也许可以尝试以下解决方案:
<nav>
<ul>
<li class="overlapping_div">
<span>Text in div</span>
</li>
<li class="overlapping_div">
<span>Text in div</span>
</li>
</ul>
</nav>
and the CSS looks like this CSS看起来像这样
ul {
list-style: none;
}
.overlapping_div {
display: inline-block;
width: 20%;
height: 30px;
margin: 0;
position: relative;
text-align: center;
-webkit-transform: skew(-40deg);
-moz-transform: skew(-40deg);
-o-transform: skew(-40deg);
background-color: #ddd;
}
nav {
background-color: #777;
padding: 0;
}
span {
font-size: 0.8em;
position: relative;
top : 5px;
display : block;
-webkit-transform: skew(40deg);
-moz-transform: skew(40deg);
-o-transform: skew(40deg);
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.