Use :after to add border to a div - HTML CSS CSS Widget

HTML CSS examples for CSS Widget:Div Border

Description

Use :after to add border to a div

Demo Code

ResultView the demo in separate window

<html>
 <head> 
  <meta name="viewport" content="width=device-width, initial-scale=1"> 
  <style id="compiled-css" type="text/css">

div {<!-- w  ww  . ja  v  a 2s . c o m-->
   width:300px;
   height:100px;
   border-top:15px solid #C90110;
   position:relative;
}
div:after {
   position:absolute;
   border:1px solid #CCC;
   border-top:none;
   height:100%;
   width:100%;
   content:'';
   display:block;
   box-sizing:border-box;
}


      </style> 
 </head> 
 <body> 
  <div></div>  
 </body>
</html>

Related Tutorials