Solved

page works but doesn't when using media query

Posted on 2012-04-01
2
192 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
2 Comments
 
LVL 30

Accepted Solution

by:
LZ1 earned 500 total points
Comment Utility
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
Comment Utility
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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Suggested Solutions

As a result of several questions about how to use Bootstrap I thought it would be a good idea to write down the development aspect of creating a Bootstrapped website in as little time as possible. Part 1 of this article will only concentrate on g…
This article discusses how to create an extensible mechanism for linked drop downs.
In this tutorial viewers will learn how to customize the background color and font color of highlighted text using the ::selection element in CSS Begin by defining the selected text as an element in CSS by typing "::selection": Style the ::selection…
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

771 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

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now