css3 - Issue with scaling width of background-image (CSS) -


i'm havig troubles image that, using "contain" in css adds huge spacing between top image , next paragraph. when use "cover" there no spacing issue pictures width high.

i'm using in css

.headerline{ position: relative; width: 100%; overflow: hidden; height: auto; background-repeat: no-repeat; background-position: center top; background-image: url(../images/bgtop.jpg); -webkit-background-size: cover; -moz-background-size: cover; -o-background-size: cover; background-size: contain; 

i upoaded pictures 100% desktop, using cover, using contain , 1 wished results here: description

have considered including image <img> instead of background image? cause headerline div dynamically change height match child image.

html:

<div class="headerline">     <img src="sampleimg.jpg" alt="sample image" width="600" height="200"> </div> 

css:

.headerline img {     display: block;     width: 100%;     height: auto; } 

concerning background size w3 schools:

background cover:

scale background image large possible background area covered background image. parts of background image may not in view within background positioning area background cover scale image

background contain:

scale image largest size such both width , height can fit inside content area


Comments

Popular posts from this blog

javascript - jQuery: Add class depending on URL in the best way -

caching - How to check if a url path exists in the service worker cache -

Redirect to a HTTPS version using .htaccess -