Tapan
October 14, 2015, 12:55pm
1
Hi,
I have a div in which i have a background image via a css class, the class code is:
[code].home-top-bg
{
margin:0 0 0 0;
padding:0px;
width:100%;
background-image: url(‘…/pictures/cover.jpg’);
background-size:cover;
}[/code]
It works fine as I want, I am using bootstrap in that. The issue I have is that when the site is viewed in mobile mode etc. then that bg does’nt looks good, is it possible to change the bg to something else on the fly ???
Thanks.
use a media query which assigns a different background image.
PaulOB
October 14, 2015, 1:37pm
3
Tapan:
.home-top-bg
As Dave said just do something like this:
.home-top-bg
{
margin:0 0 0 0;
padding:0px;
width:100%;
background: url('../pictures/cover-small.jpg') no-repeat 0 0; /* small screens get this */
background-size:cover;
}
@media screen and (min-width:768px){ /* large screens get this */
.home-top-bg {
background: url('../pictures/cover.jpg') no-repeat 0 0;
background-size:cover;
}
}
1 Like
Tapan
October 16, 2015, 9:56am
4
Excellent, works like a charm! Thanks.
system
Closed
January 15, 2016, 4:56pm
5
This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.