RError.com

RError.com Logo RError.com Logo

RError.com Navigation

  • 主页

Mobile menu

Close
  • 主页
  • 系统&网络
    • 热门问题
    • 最新问题
    • 标签
  • Ubuntu
    • 热门问题
    • 最新问题
    • 标签
  • 帮助
主页 / 问题 / 1566157
Accepted
Alexandr_TT
Alexandr_TT
Asked:2024-02-13 23:15:36 +0000 UTC2024-02-13 23:15:36 +0000 UTC 2024-02-13 23:15:36 +0000 UTC

如何在箭头上制作圆角

  • 772

在此输入图像描述

我正在尝试创建菜单箭头(又名面包屑),如图所示。我查看了大量的解决方案хлебных крошек,但没有一个可以使箭头轮廓圆角,所以我决定使用clip-path。

我的代码:

.box {
      width: 425px;
      height: 90px;
      background-color: #dfdfdf;
      color: white;
      clip-path: polygon(90% 10%, 100% 50%, 90% 90%, 0% 90%, 10% 50%, 0% 10%);
      position: relative;
    }
<div class="box"></div>

我尝试使用本主题中的方法,但在这种情况下,当我们组合两个路径来创建边框时,SVG 圆角创建器不适用于内部路径。如果我们嵌套它们以将 SVG 应用到内部,它们将不适合。

如何为箭头轮廓制作圆角?

html
  • 3 3 个回答
  • 211 Views

3 个回答

  • Voted
  1. puffleeck
    2024-02-14T04:09:17Z2024-02-14T04:09:17Z

    可以吗?:3

    .y{padding: 1em;}
    .x{
      position: relative;
      padding: .2em 1em; /*!!!*/
      text-align: center;
      line-height: 1.9em; /*!!!*/
      font-size: 27px;/*!!!*/
    }
    
    .x:before, .x:after{
    content: ' ';
    color: red;
    position: absolute;
    width: 80%;
    height: 55%;
    background: lightgray;/*!!!*/
    border-radius: .25em;/*!!!*/
    z-index: -1;
    left: .5em;
    border: 2px solid blue;
    }
    
    .x:before{
    transform: skew(30deg);/*!!!*/
    top: 0;
    border-bottom: none;
    }
    
    .x:after{
    transform: skew(-30deg);/*!!!*/
    top: none;
    bottom: 0;
    border-top: none;
    }
    <div class='y'>
      <b class='x'>что</b>
      <b class='x'>есть</b>
      <b class='x'>эта</b>
      <b class='x'>стрелка,</b>
      <b class='x'>если</b>
      <b class='x'>не</b>
      <b class='x'>пара</b>
      <b class='x'>кусков</b>
      <b class='x'>skew'анутого</b>
      <b class='x'>фона?</b>
    </div>
    <hr>
    <div class='y'>
      <b class='x'>добро</b>
      <b class='x'>пожаловать</b>
      <b class='x'>куда</b>
      <b class='x'>то</b>
      <b class='x'>там</b>
    </div>

    好吧,你可以用标记中的径向渐变来堵住“尾巴”。

    • 3
  2. Best Answer
    Andrei Fedorov
    2024-02-14T10:53:46Z2024-02-14T10:53:46Z

    不幸的是,有一些小文物。

    :root {
      --skew-deg: 30deg;
      --border-width: 5px;
      --border-radius: 10px;
    }
    
    body {
      display: flex;
      min-height: 100vh;
    }
    
    .box {
      width: 425px;
      height: 90px;
      color: white;
      position: relative;
      margin: auto;
    }
    
    .box::after,
    .box::before {
      content: '';
      display: block;
      position: absolute;
      width: 100%;
      height: 50%;
      background-color: #dfdfdf;
      border: 4px solid darkblue;
      border: var(--border-width, 4px) solid darkblue;
      border-left-width: calc(4px * 1.154);
      border-left-width: calc(var(--border-width, 4px) * (2 - cos(var(--skew-deg, 30deg))));
      border-right-width: calc(4px * 1.154);
      border-right-width: calc(var(--border-width, 4px) * (2 - cos(var(--skew-deg, 30deg))));
    }
    
    .box:after {
      top: -7px;
      top: calc(-.75 * var(--border-width, 4px));
      left: 0;
      border-bottom: none;
      border-radius: 8px 8px 0 0;
      border-radius: var(--border-radius, 8px) var(--border-radius, 8px) calc(.4 * var(--border-radius, 8px)) 0;
      transform: skewx(30deg);
      transform: skewx(var(--skew-deg, 30deg));
    }
    
    .box:before {
      bottom: -7px;
      bottom: calc(-.75 * var(--border-width, 4px));
      left: 0;
      border-top: none;
      border-radius: 0 0 8px 8px;
      border-radius: 0 calc(.4 * var(--border-radius, 8px)) var(--border-radius, 8px) var(--border-radius, 8px);
      transform: skewx(calc(-1 * var(--skew-deg, 30deg)));
    }
    <div class="box"></div>

    • 3
  3. darinka poznyak
    2024-02-14T21:49:43Z2024-02-14T21:49:43Z

    .b1 {
      position: absolute;
      width: 450px;
      height: 45px;
      left: 50px;
      background: transparent;
      border-radius: 10px;
      transform: skew(30deg);
      border-top: 3px solid black;
      border-left: 3px solid black;
      border-right: 3px solid black;
    }
    
    .b2 {
      position: absolute;
      width: 450px;
      height: 45px;
      left: 50px;
      top: 45px;
      background: transparent;
      border-radius: 10px;
      transform: skew(-30deg);
      border-bottom: 3px solid black;
      border-left: 3px solid black;
      border-right: 3px solid black;
    }
    <div class="b1"></div>
    <div class="b2"></div>

    不完全一样,但比评论中的好(绿色背景)

    或者像这样:

    .b1 {
      position: absolute;
      width: 450px;
      height: 45px;
      left: 50px;
      background: transparent;
      border-radius: 7px;
      transform: skew(30deg);
      border-top: 3px solid black;
      border-left: 3px solid black;
      border-right: 3px solid black;
    }
    
    .b2 {
      position: absolute;
      width: 450px;
      height: 45px;
      left: 50px;
      top: 53px;
      background: transparent;
      border-radius: 7px;
      transform: skew(-30deg);
      border-bottom: 3px solid black;
      border-left: 3px solid black;
      border-right: 3px solid black;
    }
    <div class="b1"></div>
    <div class="b2"></div>

    • 2

相关问题

  • 具有非均匀背景的块内的渐变边框

  • 离开页脚

  • 如何将三个字段的数据收集到一封电子邮件中?

  • Html 元素刚从父元素中出来

  • 如何在css中制作这个背景?

  • 如何制作带有斜条纹的背景?

Sidebar

Stats

  • 问题 10021
  • Answers 30001
  • 最佳答案 8000
  • 用户 6900
  • 常问
  • 回答
  • Marko Smith

    我看不懂措辞

    • 1 个回答
  • Marko Smith

    请求的模块“del”不提供名为“default”的导出

    • 3 个回答
  • Marko Smith

    "!+tab" 在 HTML 的 vs 代码中不起作用

    • 5 个回答
  • Marko Smith

    我正在尝试解决“猜词”的问题。Python

    • 2 个回答
  • Marko Smith

    可以使用哪些命令将当前指针移动到指定的提交而不更改工作目录中的文件?

    • 1 个回答
  • Marko Smith

    Python解析野莓

    • 1 个回答
  • Marko Smith

    问题:“警告:检查最新版本的 pip 时出错。”

    • 2 个回答
  • Marko Smith

    帮助编写一个用值填充变量的循环。解决这个问题

    • 2 个回答
  • Marko Smith

    尽管依赖数组为空,但在渲染上调用了 2 次 useEffect

    • 2 个回答
  • Marko Smith

    数据不通过 Telegram.WebApp.sendData 发送

    • 1 个回答
  • Martin Hope
    Alexandr_TT 2020年新年大赛! 2020-12-20 18:20:21 +0000 UTC
  • Martin Hope
    Alexandr_TT 圣诞树动画 2020-12-23 00:38:08 +0000 UTC
  • Martin Hope
    Air 究竟是什么标识了网站访问者? 2020-11-03 15:49:20 +0000 UTC
  • Martin Hope
    Qwertiy 号码显示 9223372036854775807 2020-07-11 18:16:49 +0000 UTC
  • Martin Hope
    user216109 如何为黑客设下陷阱,或充分击退攻击? 2020-05-10 02:22:52 +0000 UTC
  • Martin Hope
    Qwertiy 并变成3个无穷大 2020-11-06 07:15:57 +0000 UTC
  • Martin Hope
    koks_rs 什么是样板代码? 2020-10-27 15:43:19 +0000 UTC
  • Martin Hope
    Sirop4ik 向 git 提交发布的正确方法是什么? 2020-10-05 00:02:00 +0000 UTC
  • Martin Hope
    faoxis 为什么在这么多示例中函数都称为 foo? 2020-08-15 04:42:49 +0000 UTC
  • Martin Hope
    Pavel Mayorov 如何从事件或回调函数中返回值?或者至少等他们完成。 2020-08-11 16:49:28 +0000 UTC

热门标签

javascript python java php c# c++ html android jquery mysql

Explore

  • 主页
  • 问题
    • 热门问题
    • 最新问题
  • 标签
  • 帮助

Footer

RError.com

关于我们

  • 关于我们
  • 联系我们

Legal Stuff

  • Privacy Policy

帮助

© 2023 RError.com All Rights Reserve   沪ICP备12040472号-5