如何在六边形上应用box-shadow

时间:2015-08-17 14:58:06

标签: html css

我想在六边形上给出盒子阴影

这是我的jsfiddle jsfiddle

这是我的六边形css属性

    .hex1 {
    background-color: rgba(52,152,219,.5);
    text-align: center;
    line-height: 70px;
    height: 80px;
    width: 140px;
    margin: 60px 10px;
    position: relative;
    z-index: 1;
box-shadow:2px 2px 2px 2px grey;
}
.hex1:before {
    border-top: 40px solid transparent;
    border-bottom: 40px solid rgba(52,152,219,.5);
    top: -80px;
}
.hex1:after, .hex1:before {
    border-left: 70px solid transparent;
    border-right: 70px solid transparent;
    content: "";
    position: absolute;
    left: 0;
    z-index: -1;
}
.hex1:after {
    bottom: -80px;
    border-top: 40px solid rgba(52,152,219,.5);
    border-bottom: 40px solid transparent;
}

这对我的六角形没有影响..是否有任何方法可以将五个边框和框阴影转换为六边形。 请帮忙

1 个答案:

答案 0 :(得分:1)

您可以使用这些代码....      

 #hexagon{
   background: red;
   width: 100px; height: 60px;
   position: relative;
   -moz-box-shadow: 0 0 10px rgba(0,0,0,0.7);   
  -webkit-box-shadow: 0 0 10px rgba(0,0,0,0.7);   
   box-shadow: 0 0 10px rgba(0,0,0,0.7);
 } 

http://jsfiddle.net/jelmerdemaat/5UMxW/3/