在 :after 中创建箭头并插入边框半径

弗农

我正在尝试创建一个指向顶部的箭头。箭头目前是一个基本的 CSSafter伪类。但是,我箭头的左侧和右侧需要有某种“插入”边框半径。任何想法如何解决这一问题?

由于这涉及 Electron 菜单栏应用程序,因此外部部分需要是透明的。

在此处输入图片说明

这是我目前想出的:https : //jsfiddle.net/xcpo1g2y/

亚历山大鸟

这可能是一个开始 - 但我使用了一个额外的元素,感觉有点 hacky。这个想法是通过有一个你想要的颜色的大矩形来制作倒置的边框半径,然后用border-bottom-right-radiusborder-bottom-left-radius设置覆盖形状覆盖的边缘

我没有绕过箭头的顶部,但是通过使用您的边界半径和旋转变换方法,这肯定是可能的。

body {
  background: black;
}

.header {
  background: rgba(235,238,243,1);
  height: 40px;
  width: 100%;
  position: relative;
  margin-top: 50px;
}

/* Left flange */
.header:before {
  content: "";
  position: absolute;
  background: none;
  bottom: 100%;
  left: 50%;
  border: 25px solid black;
  border-bottom-right-radius: 25px;
  transform: translateX(-137%);
  z-index: 2;
}

/* Right flange */
.header:after {
  content: "";
  position: absolute;
  background: none;
  bottom: 100%;
  left: 50%;
  border: 25px solid black;
  border-bottom-left-radius: 25px;
  transform: translateX(37%);
  z-index: 2;
}

/* Arrow base */
.header-helper {
  background: white;
  z-index: 1;
  content: "";
  position: absolute;
  bottom: 100%;
  left: 50%;
  width: 100px;
  height: 100px;
  transform: translateX(-50%);
}

/* Up arrow */
.header-helper:before {
  content: "";
  position: absolute;
  bottom: 0;
  left: 50%;
  border: 25px solid black;
  border-bottom-color: transparent;
  transform: translateX(-50%);
  background: white;
  margin-bottom: 8px;
  z-index: 2;
}
<div class="header"><div class='header-helper'></div></div>

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章