Add border to octagon shape - HTML CSS CSS Widget

HTML CSS examples for CSS Widget:Border

Description

Add border to octagon shape

Demo Code

ResultView the demo in separate window

<html>
 <head> 
  <title>ineedborder.html</title> 
  <meta name="viewport" content="width=device-width, initial-scale=1"> 
  <style id="compiled-css" type="text/css">
body {<!--  w  w w.  j  a  v  a 2  s. c  om-->
   background:Chartreuse;
}

#octagon {
   position:relative;
   width:301px;
   height:201px;
   background:green;
   position:relative;
   -webkit-box-sizing:content-box;
   -moz-box-sizing:content-box;
   box-sizing:content-box;
   display:block;
}

#octagon:before,
#octagon:after {
   content:"";
   position:absolute;
   left:0;
   right:0;
}

#octagon:before {
   top:0;
   border-bottom:31px solid yellow;
   border-left:31px solid blue;
   border-right:31px solid pink;
}

#octagon:after {
   bottom:0;
   border-top:31px solid WhiteSmoke;
   border-left:31px solid OrangeRed;
   border-right:31px solid grey;
}

.tall {
   position:absolute;
   background:red;
   width:231px;
   height:191px;
   left:36px;
   top:6px;
   z-index:2;
}

.wide {
   position:absolute;
   background:red;
   width:291px;
   height:131px;
   left:6px;
   top:36px;
   z-index:2;
}

.corner {
   position:absolute;
   background:red;
   width:46px;
   height:44px;
   z-index:2;
   transform:rotate(46deg);
}

.topleft {
   left:15px;
   top:15px;
}

.topright {
   left:242px;
   top:14px;
}

.bottomleft {
   background:red;
   left:14px;
   top:144px;
}

.bottomright {
   background:red;
   left:242px;
   top:144px;
}
</style> 
 </head> 
 <body> 
  <div id="octagon"> 
   <div class="tall"></div> 
   <div class="wide"></div> 
   <div class="corner topleft"></div> 
   <div class="corner topright"></div> 
   <div class="corner bottomleft"></div> 
   <div class="corner bottomright"></div> 
  </div>  
 </body>
</html>

Related Tutorials