user2647999
user2647999

Reputation: 11

Responsive Website - general enquiries

I'm working with my first responsive website and I'm completely at a halt, I cannot for the life of me figure out how to use these media queries and what not...

Here's what I have...

<!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>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
<title>Responsive Layout Test</title>
<!-- Media Query 1 -->
<link href="mobile.css" rel="stylesheet" type="text/css" media="screen (max-width:480px)" />
</head>

<body>
<!-- Container -->
<div id="container">
<!-- End Container -->

    <!-- Header -->
    <div id="header">
    <!-- Logo -->
        <div id="logo">
        <a href="#"><img src="images/TalonLogo.png" alt="TalonLogo" /></a>
        </div>

        <!-- Nav bar -->
        <div id="nav">
        <ul>
            <li>
            <a href="#">Test</a>
            </li>

            <li>
            <a href="#">Test</a>
            </li>

            <li>
            <a href="#">test</a>
            </li>
        </ul>
      </div>
     </div>
      <!-- End header -->

      <div id="info">w

      </div>
</div>

And the CSS:

    @media only screen   
and (min-device-width : 320px)   
and (max-device-width : 480px) {  
/* Styles */  
body {

    width: 100%
    margin: 0;
    padding: 0;
}

#container {
    width: 480px;
    margin-left: auto;
    margin-right: auto;
}

#logo {
    max-width: 100%;
    text-align: center;
} 

#nav {
    margin-top: 10.6%;
    margin-left: 4.6%;
}

Now, I do have a main style sheet obviously, and here's a problem, the whole document (no matter what size) changes the background color... Example:

Main style sheet

body {
     background: #fff;
}

but, if i go into my mobile.css

    @media only screen   
and (min-device-width : 320px) 
and (max-device-width : 480px) { 
/* Styles */ 
body {
background: #000;
}

It all turns black...isn't it meant to be if the screen size is at 480px it will change over?

Upvotes: 1

Views: 268

Answers (1)

Christopher Francisco
Christopher Francisco

Reputation: 16258

I'm pretty sure you're missing the viewport:

<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">

Upvotes: 5

Related Questions