Solved

page works but doesn't when using media query

Posted on 2012-04-01
2
193 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
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
html coding on my Tumblr blog 1 34
Set email body to html using vbscript 6 26
Form Submit falis 6 26
Refresh div via ajax without lost ccs <li> styles 8 0
Styling your websites can become very complex. Here I'll show how SASS can help you better organize, maintain and reuse your CSS code.
Finding original email is quite difficult due to their duplicates. From this article, you will come to know why multiple duplicates of same emails appear and how to delete duplicate emails from Outlook securely and instantly while vital emails remai…
In this tutorial viewers will learn how to style a corner ribbon overlay for an image using CSS Create a new class by typing ".Ribbon":  Define the class' "display:" as "inline-block": Define its "position:" as "relative": Define its "overflow:" as …
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…

896 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

19 Experts available now in Live!

Get 1:1 Help Now