Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

page works but doesn't when using media query

Posted on 2012-04-01
2
Medium Priority
?
200 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 2000 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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

This article explains how to prepare an HTML email signature template file containing dynamic placeholders for users' Azure AD data. Furthermore, it explains how to use this file to remotely set up a department-wide email signature policy in Office …
Without even knowing it, most of us are using web applications on a daily basis.  In fact, Gmail and Yahoo email, Twitter, Facebook, and eBay are used by most of us daily—and they are web applications. We generally confuse these web applications to…
In this tutorial viewers will learn how to embed Flash content in a webpage using HTML5. Ensure your DOCTYPE declaration is set to HTML5: "<!DOCTYPE html>": Use the <object> tag to embed Flash content.: To specify that the object is Flash content, d…
HTML5 has deprecated a few of the older ways of showing media as well as offering up a new way to create games and animations. Audio, video, and canvas are just a few of the adjustments made between XHTML and HTML5. As we learned in our last micr…

971 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