Vertical positioning inside anchor and button - HTML CSS CSS Layout

HTML CSS examples for CSS Layout:Position

Description

Vertical positioning inside anchor and button

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">
button, a {
   height:31px;
   display:inline-block;
   border:2px solid Chartreuse;
   vertical-align:middle;<!--  w w  w  . jav  a2 s .co m-->
   padding:0;
}

button>div, a>div {
   width:31px;
   height:11px;
   background-color:yellow;
}

a>div {
   position:relative;
   top:51%;
   transform:translateY(-51%);
}
</style> 
 </head> 
 <body> 
  <button> 
   <div class="buttonDiv"></div> </button> 
  <a href="#"> 
   <div class="anchorDiv"></div> </a>  
 </body>
</html>

Related Tutorials