position :after element to 50% of target element height - HTML CSS CSS Layout

HTML CSS examples for CSS Layout:Position

Description

position :after element to 50% of target element height

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.jav  a  2  s.  c  o m-->
   position:relative;
   height:201px;
   width:201px;
   background-color:Chartreuse;
}

div::after {
   content:"Middle";
   position:absolute;
   top:51%;
   left:0;
   transform:translateY(-51%);
}
</style> 
 </head> 
 <body> 
  <div></div>  
 </body>
</html>

Related Tutorials