Adjust box width with margins - HTML CSS CSS Layout

HTML CSS examples for CSS Layout:Box

Description

Adjust box width with margins

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">
.box {<!--from w  w w  . j av  a2 s.  c  o  m-->
   background:url('https://www.java2s.com/style/demo/Google-Chrome.png') no-repeat scroll 0 0 / cover  transparent;
   border:5px solid Chartreuse;
   box-shadow:0 0 0 6px yellow;
   outline:4px solid white;
   overflow:hidden;
}

.box:before {
   border-top:3px solid blue;
   content:"";
   margin:-10px 0 8px -8px;
   position:absolute;
   width:auto;
}
</style> 
 </head> 
 <body> 
  <div class="box">
    Lorem ipsum dolor sit amet, consectetur adip 
  </div>  
 </body>
</html>

Related Tutorials