Use negative margin - HTML CSS CSS Layout

HTML CSS examples for CSS Layout:Margin

Description

Use negative margin

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  w w  .  ja  v a2 s  .  c o  m-->
   width: 100px;
   height: 100px;
   border: solid 10px #999;
}
.top-element {
   background: red;
}
.bottom-element {
   background: blue;
   margin-left: 10px;
   margin-top:-10px;
}


      </style> 
 </head> 
 <body> 
  <div class="top-element"> 
  </div> 
  <div class="bottom-element"> 
  </div>  
 </body>
</html>

Related Tutorials