Solved

page works but doesn't when using media query

Posted on 2012-04-01
2
198 Views
Last Modified: 2012-06-27
I have a page that works with percentages by it self  using css. When I put that same css in the media query the 3rd colum drops down. I don't understand what's wrong. It's just an exercise.
index-02.html
index-04.html
0
Comment
Question by:designaire
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 30

Accepted Solution

by:
LZ1 earned 500 total points
ID: 37796020
In the media query, you'll have to specify margin-right:0 for your .col2.  It's still applying it from the css above.

Try this:
<!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" />
<title>Untitled Document</title>
<style>

body{font-family:Arial, Helvetica, sans-serif;font-size: 1em;}
#wrapper{width: 1024px;margin: 0 auto;background:#fff;}
.photo{width: 1024px;height: 187px;}
h1{padding: 25px;font-size: 2em;text-align: center}
#header{width: 1024px;background:#F93;height: 100px;}
.col1{width: 308px;padding: 10px;float: left;margin-right: 20px;background:#fff;height: 400px;}
.col2{width: 308px;padding: 10px;float: left;margin-right: 20px;background: #fff;height: 400px;}
.col3{width: 308px;padding: 10px;float: left;height: 400px;background:#fff;}
.footer{width: 1024px;background:#400000;clear:both;height: 20px;text-align: center;padding: 12px;display: block;color: #FFF;}

@media only screen and (max-width: 750px) and (min-width: 180px) {
	#wrapper{width: 85%;margin: 0 auto;}
	h1{padding: 25px;font-size: 2em;text-align: center}
	#header{width: 100%;background:#F93;height: 100px;}
	.photo{width: 100%;}
	.col1{width: 30%;padding: 1.02%;float: left;margin-right: 2%;background:#FFF;height: 100%;}
	.col2{width: 30%;padding: 1.02%;float: left;background: #FFF;height: 100%;margin-right:0;}
	.col3{width: 30%;padding: 1.02%;float: right;height: 100%;background:#fff;}
	.footer{width: 100%;background:#400000;clear:both;height: 20px;text-align: center;padding: 12px;display: block;color: #FFF;}
}

</style>
</head>

<body>
<div id="wrapper">
<div id="header" >
<h1>Header</h1>

</div>
<div class="photo"><img src="images/photo.jpg" width="100%"  alt="gf" /></div>


<div class="col1">
  <p>about how to handle their share of the $656 million prize.</p>
  <p>Tickets sold in Kansas, Illinois and Maryland matched all six numbers in   Friday's Mega Millions drawing. None of the winners had come forward as of   Sunday evening.</p>
  <p>Advisers say jackpot winners should take a &quot;cooling off&quot; period of three to   six months. During that time, they should avoid making any big decisions about   their investments or spending.</p>
  <p>&quot;People need time to adjust to this huge change in their lives,&quot; said Michael   Garrison, of Garrison Financial Inc., in Chatham, Mass. &quot;The fear is that people   get this lump sum and go crazy,&quot; he said.</p>
</div>
<div class="col2">
  <p>MILWAUKEE (AP) — President Barack Obama's administration launched a multi-pronged assault on Mitt Romney's values and foreign policy credentials Sunday, while a fresh set of prominent Republicans rallied behind the GOP front-runner as the odds-on nominee, further signs the general election is overtaking the primary season.</p>
  <p>A defiant Rick Santorum outlined plans to leave Wisconsin the day before the state's contest Tuesday, an indication that the conservative favorite may be in retreat, his chances to stop Romney rapidly dwindling.</p>
  <p>A defiant Rick Santorum outlined plans to leave Wisconsin the day before the state's contest Tuesday, an indication that the conservative favorite may be in retreat, his </p>
</div><div class="col3">
  <p>&quot;I think the chances are overwhelming that (Romney) will be our nominee,&quot; Senate Minority Leader Mitch McConnell said Sunday on CNN's &quot;State of the Union.&quot; ''It seems to me we're in the final phases of wrapping up this nomination. And most of the members of the Senate Republican conference are either supporting him, or they have the view that I do, that it's time to turn our attention to the fall campaign and begin to make the case against the president of the United States.&quot;</p>
  <p>Both Secretary of State Hillary Clinton and Vice President Joe Biden went after Romney Sunday, underscoring the belief inside Obama's Chicago re-election headquarters that Romney will — sooner than later — secure the right to face Obama </p>
</div>
<div class="footer"> footer
</div>
</div>
</body>
</html>

Open in new window

0
 

Author Closing Comment

by:designaire
ID: 37796405
You're right, I forgot I didn't take that out. When you're learning something new you never know if you're making a stupid little mistake or totally off base. You're lucky, I wasn't going to give so many points but somehow in IE9 I couldn't change the slider! Thanks for your help
0

Featured Post

Are You Using the Best Web Development Editor?

The worlds of web hosting and web development are constantly evolving. Every year we see design trends change, coding standards adapt and new frameworks/CMS created. With such a quick pace of change it’s easy to get lost trying to keep up.

See if your editor made the list.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When it comes to write a Context Sensitive Help (an online help that is obtained from a specific point in state of software to provide help with that state) ,  first we need to make the file that contains all topics, which are given exclusive IDs. …
Originally, this post was published on Monitis Blog, you can check it here . Websites are getting bigger and more complicated by the day. Video, images and custom fonts are all great for showcasing your product or service. But the price to pay in…
In this tutorial viewers will learn how to embed custom externally-hosted Google Fonts using the Google Font API in CSS Go to the Google Fonts website at google.com/fonts: Browse or search based on font properties or name to find a suitable font for…
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.

617 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question