html - Background image height issue on div -
i have div background image applied (#wrapper) , first child of div absolute positioned color overlay div (.bg-overlay) reason whenever have .bg-overlay div doesn't seem allow background image grow in height when other elements placed within it.
i trying apply bottom padding p tag within #wrapper seems overflow when looking @ inspect tool. dont quite understand why main #wrapper div isnt growing in height. have set min-height of 200px. i'm sure simple im missing here. appreciate help, here markup.
#wrapper { background-image: url("http://placehold.it/350x150"); background-repeat: no-repeat; background-size: cover; background-position: center center; position: relative; min-height: 200px; } .bg-overlay { background-color: rgba(75, 78, 83, 0.6); width: 100%; height: 100%; position: absolute; top: 0; left: 0; } #content-wrap p { padding-bottom: 100px; } <section id="wrapper"> <div class="bg-overlay"> <div id="content-wrap"> <h1> heading heading heading </h1> <p> lorem ipsum dummy text of printing , typesetting industry. lorem ipsum has been industry's standard dummy text ever since 1500s, when unknown printer took galley of type , scrambled make type specimen book. has survived not 5 centuries, leap electronic typesetting, remaining unchanged. popularised in 1960s release of letraset sheets containing lorem ipsum passages, , more desktop publishing software aldus pagemaker including versions of lorem ipsum. </p> </div> </div> </section>
#wrapper not going grow add content .bg-overlay because absolute positioned. means it's taken out of normal document flow , doesn't take space. far #wrapper concerned it's empty , doesn't have height.
you'll have move content out of .bg-overlay or not use absolute positioning on #wrapper adjust add content. use pseudo element create overlay. way can simplify markup bit.
position: relative; , z-index: 5; on #content-wrap elevates above pseudo element isn't under overlay.
#wrapper { position: relative; z-index: 0; background-image: url("http://placehold.it/350x150"); background-repeat: no-repeat; background-size: cover; background-position: center center; } #wrapper::before { content: ''; position: absolute; top: 0; right: 0; bottom: 0; left: 0; z-index: 5; background-color: rgba(75, 78, 83, 0.6); } #content-wrap { position: relative; z-index: 5; } #content-wrap p { color: white; padding-bottom: 100px; } <section id="wrapper"> <div id="content-wrap"> <h1> heading heading heading </h1> <p> lorem ipsum dummy text of printing , typesetting industry. lorem ipsum has been industry's standard dummy text ever since 1500s, when unknown printer took galley of type , scrambled make type specimen book. has survived not 5 centuries, leap electronic typesetting, remaining unchanged. popularised in 1960s release of letraset sheets containing lorem ipsum passages, , more desktop publishing software aldus pagemaker including versions of lorem ipsum. </p> </div> </section>
Comments
Post a Comment