Auto-resize background-image to fit smaller windows and mobile devices - HTML/CSS -


although there many answers question, cannot find 1 fits needs. when use site on mobile, or make browser window on laptop small, lose full image i'm using background-image.

html:

<div class="compete">     <div class="container">         <h2>compete</h2>         <p>winners win</p>     </div> </div> 

css:

.compete{   background-image:url('handlebars.jpg');   height:450px;   background-repeat: no-repeat;   background-size: cover;   border-bottom:1px solid #ff6a00; } .compete .container {   position:relative;   top:40px; } 

any ideas on how keep using backgrond-image , yet have auto-resize can see full image on mobile/small window?

try setting background-size:100% 100%

css

.compete{   background-image:url('http://dummyimage.com/600x400/000/fff'); height:450px; background-repeat: no-repeat; background-size: 100% 100%; border-bottom:1px solid #ff6a00; } .compete .container { position:relative; top:40px; } 

html

<div class="compete"> <div class="container">     <h2>compete</h2>     <p>winners win</p> </div> 

do come if still face issue.


Comments

Popular posts from this blog

c# - Binding a comma separated list to a List<int> in asp.net web api -

Delphi 7 and decode UTF-8 base64 -

html - Is there any way to exclude a single element from the style? (Bootstrap) -