0

I have an issue with media queries. I want my main div to have a width of 960px but if the screen is smaller than 960 px - I want it to be 80% of any current width.

I get only 80% from 960px and not 80% out of everything smaller (for example: 80% of 800px, 80% of 700px).

HTML:

<body>
    <div class="main">
         Some big amound of text
    </div>
</body>

CSS:

body{
    width:100%;
}

.main {
    display: block;
    height: 600px;
    width: 960px;
}

@media (max-width: 960px) {
    .main {
        width:80%;
    }
}

I want it to be fluid but it is fixed only on 2 positions: 960px and 80% of 960px - how do I make it fluid?

4
  • You need to post more of your html and css. Perhaps recreate the issue in jsfiddle.net as at the moment the css you have posted should be working. Commented Nov 26, 2011 at 20:50
  • What browser are you using? I've tested the code you provided in the latest versions of Safari, Chrome, Firefox, and Opera for OSX and it works as you said you'd like it to. Commented Nov 26, 2011 at 21:06
  • It works in chrome. I was using firefox 5.0 - I guess that was the problem... will update it and recheck. Commented Nov 26, 2011 at 21:15
  • okay - the problem was the old firefox browser. Commented Nov 26, 2011 at 21:18

2 Answers 2

3

For the sake of anyone else who finds this -- Firefox has supported media queries since version 3.5. I'm not sure why your copy of FF5 wasn't working, but it wasn't due to a lack of media query support. Here's a demo page. I tested it in FF3.6, and it works fine: http://oscorp.net/experiments/media-queries/

Sign up to request clarification or add additional context in comments.

Comments

1

I solved the problem -

I was using firefox 5.0 which I assume didn't support this feature - I guess that was the problem.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.