Dave's Brain

Browse - Programming Tips - How can I put two divs on top of each other?

Date: 2017dec20
Language: css

Q.  How can I put two <div>s on top of each other?

A.  Use position:absolute like this.

<!DOCTYPE html> <meta charset='utf-8'> <style> .parent { position: relative; margin: 0px; padding: 0px; } .child { position: absolute; margin: 0px; padding: 0px; left: 0px; right: 0px; } </style> <div class='parent'> <div class='child'>ONE</div> <div class='child'>two</div> </div>

Add a comment

Sign in to add a comment
Copyright © 2008-2018, dave - Code samples on Dave's Brain is licensed under the Creative Commons Attribution 2.5 License. However other material, including English text has all rights reserved.