Welcome to the Treehouse Community
Looking to learn something new?
Lindsay BarrettPython Web Development Techdegree Student 7,357 Points
Content won't center with Absolute positioning
I have an image I am trying to place on the bottom of its parent element. I have the parent element set to relative and the img element to absolute.
The image is acting correctly when I move it up or down, but it will not center within it's parent element. I have set the left and right positing elements set to auto, but it is centering the element within its parent element.
Here is my code: https://w.trhou.se/o9qx43sjb8
Thank you for your help!
Dinu Mihai2,761 Points
Hi, try this in index.html <div class="content4"> <div class="container"> <h1>BOOST UP YOUR LOCAL BUSINESS</h1> <p>LORUM IMPSUM IS SIMPLY A DUMMY TEXT USED FOR THIS BUSINESS. THANK YOU FOR YOUR HELP.</p> <textarea>full name</textarea> <textarea>email address</textarea> <textarea>phone</textarea> </div> <img src="http://pngimg.com/upload/laptop_PNG5910.png" width="450" height="237" alt=""/> </div>
Get that img tag outside container and remove all css rules applied to img selector, it will be centered due to text-align: center property of content4 class.