CSS3创建圆角三角形元素

her*_*ron 0 html css css3 html-lists css-shapes

我只知道圆边的方式.无法弄清楚如何创建这种无图像ul li标签.如你所见,它不完全是三角形:它的顶部和底部有点圆润.是否可以使用css3创建与下图最相似的内容?如果有,怎么样?

先感谢您!

在此输入图像描述

Gil*_*mbo 8

标记:

首先,你必须定义你的化妆如下:

<menu type=list>
    <li>home</li> 
    <li>work</li>  
</menu>
Run Code Online (Sandbox Code Playgroud)

然后使用skew,rotate,box-shadow,border-radius和CSS Pseudo-elements,如下所示:

来源:http ://www.w3schools.com/css3/css3_2dtransforms.asp http://www.w3schools.com/cssref/css3_pr_box-shadow.asp http://www.w3schools.com/cssref/css3_pr_border-radius. asp http://www.w3schools.com/css/css_pseudo_elements.asp

演示1:http://jsfiddle.net/kougiland/mVu2z/5/ 在此输入图像描述

menu{
   position:relative;
   width:320px;
   height:40px;
}

li{
    float:left;
    width:50%;
    background-color:red;
    list-style:none;
    position:relative;
    height:54px;
    text-align:center;
    line-height:50px;
    color:white;
}

li:before,li:after{
    position: absolute;
    content: "";
    height: 32px;
    width: 32px;
    border-radius: 4px;
    background-color: red;
    top: 11px;
    -webkit-transform: rotate(45deg) skew(16deg,16deg);
    -moz-transform: rotate(45deg) skew(16deg,16deg);
    transform: rotate(45deg) skew(16deg,16deg);
}
li:before{
    left:-15px;
}
li:after{
    right:-15px;
}
li:nth-child(2):before{
    box-shadow: 0px 0 0 black,-4px 4px 0 black;
}
Run Code Online (Sandbox Code Playgroud)

演示2:http://jsfiddle.net/kougiland/mVu2z/4/ 在此输入图像描述

风格:

menu{
   position:relative;
   width:320px;
   height:40px;
}

li{
    float:left;
    width:50%;
    background-color:red;
    list-style:none;
    position:relative;
    height:54px;
    text-align:center;
    line-height:50px;
    color:white;
}

li:before,li:after{
    position: absolute;
    content: "";
    height: 26px;
    width: 26px;
    border-radius: 4px;
    background-color: red;
    top: 14px;
    -webkit-transform: rotate(45deg) skew(30deg,30deg);
    -moz-transform: rotate(45deg) skew(30deg,30deg);
    transform: rotate(45deg) skew(30deg,30deg);
}
li:before{
    left:-13px;
}
li:after{
    right:-13px;
}
li:nth-child(2):before{
    box-shadow: 0px 0 0 black,-4px 4px 0 black;
}
Run Code Online (Sandbox Code Playgroud)

演示3:http://jsfiddle.net/kougiland/mVu2z/在此输入图像描述

menu{
   position:relative;
   width:320px;
   height:40px;
}

li{
    float:left;
    width:50%;
    background-color:red;
    list-style:none;
    position:relative;
    height:54px;
    text-align:center;
    line-height:50px;
    color:white;
}

li:before,li:after{
    position:absolute;
    content:"";
    height:40px;
    width:40px;
    border-radius:4px;
    background-color:red;
    top: 7px;
    -webkit-transform:rotate(45deg);
    -moz-transform:rotate(45deg);
    transform:rotate(45deg);
}
li:before{
    left:-20px;
}
li:after{
    right:-20px;
}
li:nth-child(2):before{
    box-shadow: 0px 0 0 black,-4px 4px 0 black;
}
Run Code Online (Sandbox Code Playgroud)

  • 这是一流的... +1但我们有相同的解决方案:) (2认同)