Home  >  Article  >  Web Front-end  >  CSS3之尖角标签_html/css_WEB-ITnose

CSS3之尖角标签_html/css_WEB-ITnose

WBOY
WBOYOriginal
2016-06-24 11:48:521295browse

如图所示,Tag标签的制作通常使用背景图片,现在用CSS3代码就能实现尖角效果(需浏览器支持CSS3属性).

运用CSS3样式实现尖角标签,只需要写简单的HTML结构和CSS样式.

Tag1 Tag2 Tag3 Tag4

css主要利用伪元素来实现尖角

a{    dispaly:inline-block;    position:relative;    background:#ccc;    color:green;    line-height:1em;    margin:0 10px;    padding:3px;}a:before{    position:absolute;    content:"";    width:0;    height:0;    border:transparent 0.74em solid;    border-right-color:#ccc;    top:0;    left:-1.4em    }

利用伪元素实现的尖角基于整个a标签绝对定位显示在左侧,注意行高和定位都是用的em单位.

简单实现效果看截图:

 

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn