html - 标签状形状的轮廓

标签 html css

我在 HTML/CSS 中制作了一个类似标签的形状,如下所示 - http://jsfiddle.net/RuXyP/

.tag {
float: left;
text-align: center;
height: 14px;
width: 110px;
background-color: #2e353d;
color: #FFFFFF;
padding-top: 2px;
margin-top: 1px;
font-size: 10px;
}
.arrow-right {
width: 0;
height: 0;
float: left;
margin-top: 1px;
border-top: 8px solid transparent;
border-bottom: 8px solid transparent;
border-left: 8px solid #2e353d;
}

我正在尝试为其添加大纲,目前已达到此目的 - http://jsfiddle.net/RuXyP/1/

但是,我正在努力研究如何向箭头位添加轮廓。 我不能使用边框,因为箭头是这样创建的 我不能使用轮廓,因为它不能为各个边指定

有什么办法可以做到这一点吗?

最佳答案

我不喜欢为此使用伪选择器,而是只为三 Angular 形使用两个 div,一个比另一个大 1px,然后您只需将边距移到第二个 div 上。像这样:

.arrow-border {
    width: 0;
    height: 0;
    float: left;
    margin-top: 1px;
    border-top: 9px solid transparent;
    border-bottom: 9px solid transparent;
    border-left: 9px solid #FF00FF;
}

.arrow-right {
    width: 0;
    height: 0;
    float: left;
    margin-left: -9px; /* Width of .arrow-border's border */
    margin-top: 2px;
    border-top: 8px solid transparent; /* One less than .arrow-border's border width */
    border-bottom: 8px solid transparent;
    border-left: 8px solid #2e353d;
}

演示:http://jsfiddle.net/RuXyP/4/

Nit:请记住,如果将其放入比箭头小的容器中,箭头可能会脱落。通常这应该不是问题。

关于html - 标签状形状的轮廓,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22950049/

相关文章:

html - 中间元件流体高度

html - Internet Explorer 11 自动换行不起作用

html - 如何在 HTML/CSS 中设置百分比高度值

c# - Foreach输出成两列cshtml

html - CSS Foundation 使左 div 在小屏幕上低于右 div

css - HTML DIV 按钮定位

html - 在表格中滚动以避免溢出

javascript - 将多个 .php 文件加载到一个 div 中

css - CSS 规范中的 "propagated to the viewport"是什么意思?

html - 为什么 flex 元素不缩小过去的内容大小?