html - css+html 中带边框的三 Angular 形侧边标签

标签 html css tabs

我需要这样的东西 triangle side navigation tabs ,我试着这样做,使用 :after

.tabs input + label:after{
content:"";
float:left;
position:absolute;
top:0;
right:-12px;
width:0;
height:0;
border-top: 15px solid black;
border-left: 11px solid transparent;
border-bottom: 16px solid black;    
}

但我有类似 this 的东西

我需要带边框的三 Angular 形边为 1 px,感谢您的帮助。 +1 如果你包含一个 JSFiddle。

最佳答案

  • 使用 ::before 伪元素创建两个三 Angular 形,使用颜色较深的边框叠加在一起。
  • 接下来,使用与您的元素颜色相同的::after 伪元素覆盖不需要的部分。这可以使用与 ::before 元素相同的规则来完成,将 1px 定位到左侧,创建一个 1px 宽箭头
  • 最后,对于箭头的尖端,将 1px box-shadow 添加到两个具有相同颜色的伪元素的右边缘。注意:如果希望箭头更宽,阴影也要相应调整。
  • 请记住排除 :first-of-type 以避免在第一个元素之前出现箭头。

代码:

li:not(:first-of-type)::before, li:not(:first-of-type)::after{
  content:'';
  display: block;
  position: absolute;
  top: 0;
  left: -10px;
  width:0;
  height:0;
  border-style: solid;
  border-width: 15px 0 15px 10px;
  border-color: blue transparent;
  box-shadow: 1px 0 0 blue;
}
li:not(:first-of-type)::after{
  left: -9px;
  border-color: lightblue transparent;
  box-shadow: 1px 0 0 lightblue;
}

fiddle :https://jsfiddle.net/ilpo/r5enysmf/

关于html - css+html 中带边框的三 Angular 形侧边标签,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37307916/

相关文章:

html - 流体宽度表格单元格中的文本溢出省略号

html - 显示 : table-cell same space for all cells

html - 我需要帮助才能在较小的设备上创建特定的内容 View

c# - 在 C# 中处理表单的大型源代码文件

javascript - JQuery 简单标签导航

html - 有页脚问题(重叠内容、宽度问题)。你能帮助我吗?

html - CSS 中的垂直文本放置按文本长度偏移

html - 为什么这些被复选框破坏的单选按钮在被选中时会跳转?

javascript - 在与父级相同的选项卡中打开窗口,其中包含来自父级的变量

html - 在 html5 中对齐图像