• So I have a main div thats a slideshow with position: relative, and a div on top with text and img that has position: absolute, however if I add position: absolute it makes the div wider than it should, and its off centered, why is that? And I am unable to position it or center it, Ideas?

    Look on my home page: https://www.perhamlife.com

Viewing 4 replies - 1 through 4 (of 4 total)
  • Absolute position takes it out of document flow, so it doesn’t inherit the width of its containing div.

    To fix this just assign the same width property of its containing div to it. Try adding max-width: 980px; to it.

    Thread Starter mkymn8828

    (@mkymn8828)

    that worked thank you! I still need to figure how I can center it or move it around, would I just use top, bottom an so on for values?

    Yes, that’s how the absolute position work.

    Please make sure that you check the site in different screen resolution, so that the design works in different devices. Sometimes we have to adjust the design to best serve each particular range of screenwidth via CSS media query.

    Thread Starter mkymn8828

    (@mkymn8828)

    thank you so much for your help, one last thing if I have a div thats absolute, how could I make the bg color be 100% width across the screen for all resolutions?

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Place div within another div’ is closed to new replies.