Centre a overflowing element within its container - HTML CSS CSS Property

HTML CSS examples for CSS Property:overflow

Description

Centre a overflowing element within its container

Demo Code

ResultView the demo in separate window

<html>
 <head> 
  <style>
* {<!--  w ww  . j av  a  2 s .co m-->
   padding:0;
   margin:0;
}

.parent {
   width:100%;
   height:401px;
   overflow:hidden;
   background-color:Chartreuse;
   position:relative;
}

.wrapper {
   position:absolute;
   left:51%;
}

.child {
   width:941px;
   height:301px;
   background-color:yellow;
   border:11px solid;
   position:relative;
   left:-51%;
}
</style> 
 </head> 
 <body> 
  <div class="parent"> 
   <div class="wrapper"> 
    <div class="child"></div> 
   </div> 
  </div>  
 </body>
</html>

Related Tutorials