【问题标题】:CSS - Curved Corner after using border-left and border-bottomCSS - 使用border-left和border-bottom后的弯曲角
【发布时间】:2015-07-20 22:35:45
【问题描述】:

我已经使用左边框和下边框为引导导航栏创建了一种单边平行四边形形状,但我还需要在保持左侧透明的同时将右侧弯曲。

目前的结果:

想要的结果:

我尝试过使用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/

【问题讨论】:

  • 你的 jsfiddle 显示了你想要的结果
  • 仅作为我在paint中创建的图像。
  • 结果取决于浏览器,你需要添加你所拥有的-webkit-border-top-right-radius: 2em; -moz-border-radius-topright: 2em; border-top-right-radius: 2em;来考虑webkit浏览器和firefox

标签: html css css-shapes


【解决方案1】:

在您的示例中,蓝色条是底部边框。它不起作用,因为你不能给边界的“末端”一个弯曲的外观。

您可以尝试应用蓝色作为背景并使用: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">

编辑了 sn-p 以获得更好的代码

【讨论】:

    【解决方案2】:

    将此添加到右侧弯曲的 css 中:

        border-top-right-radius: 2em;
        border-bottom-right-radius: 2em;
    

    【讨论】:

    • 这只弯曲了右下角,而不是顶部
    • 应该是border-top-right-radius: 2em 2em;和边界右下角半径:2em 2em;
    猜你喜欢
    • 1970-01-01
    • 2011-03-08
    • 2019-03-26
    • 1970-01-01
    • 2021-11-19
    • 1970-01-01
    • 2020-05-20
    • 1970-01-01
    • 2011-09-10
    相关资源
    最近更新 更多