CSS - 使用 border-left 和 border-bottom 后的曲线角
CSS - Curved Corner after using border-left and border-bottom
我已经使用 border-left 和 border-bottom 为 bootstrap 导航栏创建了一种单边平行四边形形状,但我还需要在保持左侧透明的同时将右侧弯曲。
当前结果:
想要的结果:
我试过使用 border-top-right-radius 但没有任何反应:
.navbar {
position: relative;
min-height: 50px;
margin-bottom: 20px;
border: 1px solid transparent;
height: 20px;
width: 100px;
border-bottom: 50px solid rgba(58, 162, 178, 0.5);
border-left: 50px solid transparent;
/* Tried */
border-top-right-radius: 2em;
}
我在这里做了一个 JSFiddle:http://jsfiddle.net/6qfbhxty/
将此添加到您的 css 弯曲的右侧:
border-top-right-radius: 2em;
border-bottom-right-radius: 2em;
在您的示例中,蓝色条是底部边框。它不会起作用,因为你不能给边框的 "end" 一个弯曲的外观。
您可以尝试将蓝色用作背景并使用 :before
创建三角形。
请注意给背景和边框应用相同的颜色!
body {
background-image: url("http://lorempixel.com/800/800/abstract");
background-attachment: fixed;
background-repeat: no-repeat;
background-size: cover;
width: 100%;
height: 100%;
}
.navbar {
position: relative;
height: 50px;
margin: 0px 0px 20px 50px;
width: 100px;
background: rgba(58, 162, 178, 0.8);
border-top-right-radius: 16px 25px;
border-bottom-right-radius: 16px 25px;
}
.navbar:before {
content: ' ';
position: absolute;
width: 0;
height: 0;
left: -50px;
border: solid transparent;
border-width: 0 0 50px 50px;
border-bottom-color: rgba(58, 162, 178, 0.8);
}
h3 {
background: white;
}
<div class="navbar" style="width:75%;">
<div class="navbar-collapse collapse navbar-responsive-collapse"></div>
<br>
<br>
<br>
<h3>Wanted outcome (shape wise):</h3>
<img src="http://i.stack.imgur.com/wnFO2.png">
编辑了代码片段以获得更好的代码
我已经使用 border-left 和 border-bottom 为 bootstrap 导航栏创建了一种单边平行四边形形状,但我还需要在保持左侧透明的同时将右侧弯曲。
当前结果:
想要的结果:
我试过使用 border-top-right-radius 但没有任何反应:
.navbar {
position: relative;
min-height: 50px;
margin-bottom: 20px;
border: 1px solid transparent;
height: 20px;
width: 100px;
border-bottom: 50px solid rgba(58, 162, 178, 0.5);
border-left: 50px solid transparent;
/* Tried */
border-top-right-radius: 2em;
}
我在这里做了一个 JSFiddle:http://jsfiddle.net/6qfbhxty/
将此添加到您的 css 弯曲的右侧:
border-top-right-radius: 2em;
border-bottom-right-radius: 2em;
在您的示例中,蓝色条是底部边框。它不会起作用,因为你不能给边框的 "end" 一个弯曲的外观。
您可以尝试将蓝色用作背景并使用 :before
创建三角形。
请注意给背景和边框应用相同的颜色!
body {
background-image: url("http://lorempixel.com/800/800/abstract");
background-attachment: fixed;
background-repeat: no-repeat;
background-size: cover;
width: 100%;
height: 100%;
}
.navbar {
position: relative;
height: 50px;
margin: 0px 0px 20px 50px;
width: 100px;
background: rgba(58, 162, 178, 0.8);
border-top-right-radius: 16px 25px;
border-bottom-right-radius: 16px 25px;
}
.navbar:before {
content: ' ';
position: absolute;
width: 0;
height: 0;
left: -50px;
border: solid transparent;
border-width: 0 0 50px 50px;
border-bottom-color: rgba(58, 162, 178, 0.8);
}
h3 {
background: white;
}
<div class="navbar" style="width:75%;">
<div class="navbar-collapse collapse navbar-responsive-collapse"></div>
<br>
<br>
<br>
<h3>Wanted outcome (shape wise):</h3>
<img src="http://i.stack.imgur.com/wnFO2.png">
编辑了代码片段以获得更好的代码