This is my first attempt at utilizing a different CSS for mobile devices vs. regular screens.
To do this, I’m using-
@media only screen
and (min-device-width : 320px)
and (max-device-width : 480px) {
background: url('img/background.jpg') no-repeat center center fixed;
background-size: cover;
height: 100%;
}
However, it doesn’t seem to be working (I can only test on iPhones). Any ideas as to why that may be? I’ve also tried @media all to no avail.
The body is the HTML element that you are targeting so assuming you have a
<body>tag in your HTML the CSS styles above will be applied when the device meets the width criteria.EDIT : Also try the background like this, if the file is there should work…
EDIT : Turns out an
!importanttag fixed this issue, you can read more about CSS precedence here.