html - div background images separate when scaling to mobile -
i'm making website using dreamweaver cc 2015 , it's fluid grid layout. got design want when resize browser simulate tablet or smartphone images not stay together?
you can see on page: www.sverkel.dk
this issue value of background-size. setting 100%, should setting 100% 100%. once fix in style sheet, images stay without leaving gap between them. example:
#midt { background-image: url(../billeder/bgmidt.jpg); background-repeat: no-repeat; height: 100%; background-size: 100% 100%; } why happen? if background-size gets 1 value, interpreted value of width of image, , value of height set auto. need specify 2 values setting both width , height (source).
as explained in comments below, may cause issues rounded borders not looking nice image stretched.
if can, may idea move css-only solution (without images), adapt screen size , keep proportions time. save bandwidth you'll stop using 100kb in images. con may need tricks make work in old browsers (although doesn't seem need that, see jsfiddle below).
something (you can see more in-depth sample on jsfiddle):
body { background: url(http://www.sverkel.dk/billeder/bg.jpg) center center; } .gridcontainer { width:90%; max-width:1200px; border-radius:10px; box-shadow:0px 0px 16px rgba(0,0,0,0.8); margin:auto auto; text-align:center; background:#e5e5e5; } .gridcontainer #top { background: #b4b4b4; /* old browsers */ background: linear-gradient(to bottom, #b4b4b4 0%,#e5e5e5 100%); /* w3c */ height:125px; border-radius:10px 10px 0px 0px; } .gridcontainer #bund { background: #b4b4b4; /* old browsers */ background: linear-gradient(to bottom, #e5e5e5 0%,#b4b4b4 100%); /* w3c */ height:125px; border-radius:0px 0px 10px 10px; } .gridcontainer #menu { background: #cf5858; /* old browsers */ background: linear-gradient(to bottom, #cf5858 0%,#902727 100%); /* w3c */ height:45px; line-height:45px; color:rgba(255,255,255,0.9); border-radius:10px; margin:16px; } <br/> <div class="gridcontainer clearfix"> <div id="top" class="fluid"></div> <div id="menu" class="fluid">forside - produkter - priser - om - kontakt</div> <div id="midt" class="fluid">hvad så der?</div> <div id="bund" class="fluid"></div> </div>
Comments
Post a Comment