As the title's saying, I can't set media screen width-specific CSS for my PHP webpage.
Here is my <head>
section of my index.php
:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title><?php echo SITENAME; ?> - <?php echo SITEDESC; ?></title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0; minimumscale=1.0, maximum-scale=1.0; user-scalable=0;" /> <!-- for responsive coding, the "Viewport" meta tag -->
<!--[if lt IE 9]>
<script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
<script type='text/javascript' src='scripts/respond.min.js'></script> <!-- for responsive mobile themes -->
<link type="text/css" rel="stylesheet" href="style.css"/>
</head>
For my HTML element <header> ... </header>
, in my CSS (in style.css
), I specified:
header{
background: #1e5799;
min-height: 40px;
max-height: 136px;
}
But using "Web Developer" toolbar's Resize » View Responsive Layouts is showing some fall in different width device layouts.
For example:
In my <header>
tag, the inner elements are getting out, so I need to increase the height of the header. So I specified in style.css
:
/* Media Queries for Different Types of Mobile Devices */
/* Mobile portrait (320 x 480) */
@media all and (max-device-width: 320px) {
header{
height: 136px !important;
background-color: #FF0000;
}
}
But it's not working. :(
What am I missing about responsive CSS?
EDIT
After the first 2 answers, with their suggestions, I tried using:
@media screen and (max-width: 320px) {
header{
height: 136px !important;
background-color: #FF0000;
}
}
And yes, I put my media CSS at the bottom of style.css
.
I also tried separating the mobile.css
as:
<link type="text/css" rel="stylesheet" media="screen and (max-device-width: 480px)" href="css/mobile.css" />
Where I tried placing the following code:
header{
height: 130px;
}
Still it's not working.