Solved

media query logo centering problem

Posted on 2012-04-08
13
156 Views
Last Modified: 2012-04-10
I have a page with a logo. When The browser pulls in there is media query code and the css changes. The top  menu drops down to the second line and the logo is supposed to be centered. For some reason the logo is still flush left and I can't figure out why
---index-09.html
0
Comment
Question by:designaire
  • 5
  • 4
  • 3
  • +1
13 Comments
 
LVL 16

Expert Comment

by:HagayMandel
ID: 37822355
Change the "logo" style to this:
.logo{
	width: 161px;
	height: 216px;
	margin-right: auto;
	margin-left: auto;
}

Open in new window


Another tip: Don't use the alt tag on images, use the title tag instead.
0
 

Author Comment

by:designaire
ID: 37823259
No, it didn't work. I think it's because of the .menuBackground style. It has a background when it's full frame but if the browser is smaller then the buttons move to the next line but it's still in a div with a class called .menubackground. I don't need it anymore and I plan to put the background to none if I didn't in the sample, but if I hide it the logo and buttons won't show up.

Thanks for the tip on the alt tag.
0
 
LVL 30

Expert Comment

by:LZ1
ID: 37823296
Can you show a sample URL?  It's going to be difficult to try and see what your talking about with no images.
0
Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

 
LVL 16

Expert Comment

by:HagayMandel
ID: 37823507
It works!
Checked with IE7 & 8, Chrome and Firefox.
If it doesn't work on your code, there must be something else,  so it's better to have a live page as LZ1 suggested.
0
 

Author Comment

by:designaire
ID: 37823884
I'll post it up later tonight. I ended up using a left margin, but if I can't get it working it centered, I'd rather do that.
0
 
LVL 6

Expert Comment

by:uzzidesign
ID: 37823928
It's because of the float you have on the logo. Remove the float.

Floats remove the element from its normal relative flow in the tree and forces the adjacent elements to fill the space once occupied by it. The margin: 0 auto only works when those left and right margins can calculate themself (auto) relative to it's parent and adjacent elements, but floating it makes the element "unaware" of it's parent and adjacent elements.
0
 

Author Comment

by:designaire
ID: 37826012
http://designaste.com/class/__fin_04.htm

Here's the link. You have to pull the browser in befor it changes to center. I have a clear on the left in the logo. It still doesn't work.

Thanks for you help.
0
 
LVL 30

Expert Comment

by:LZ1
ID: 37826091
On line 92 of http://designaste.com/class/__fin_04.htm, you have a .logo class which is still maintaining a float:left.  This is your issue.  

To the other .logo class on line 201, add float:none !important; and you should be fine
0
 
LVL 16

Expert Comment

by:HagayMandel
ID: 37826262
I can only address you to my answer above (#37822355):
in the .logo class:
REMOVE:  float: left;
ADD: margin-right: auto;
          margin-left: auto;
0
 

Author Comment

by:designaire
ID: 37827211
It has to have float: left in the beginning before the media query otherwise it drops down too early.
0
 

Author Comment

by:designaire
ID: 37827282
Float: none; worked. Then margin: 0 auto or margin-left: auto and margin-right: auto.

I didn't realize there was a float none. Why doesn't Float: clear work???
0
 
LVL 30

Accepted Solution

by:
LZ1 earned 500 total points
ID: 37827285
I'm saying to add float:none !important to the media query .logo class.

Line 201 in your page you posted above:

                  .logo{
                        width: 161px;
                        margin-left: auto;
                        margin-right: auto;
                        clear: left;
                        float:none !important;
                  }
0
 
LVL 30

Assisted Solution

by:LZ1
LZ1 earned 500 total points
ID: 37827291
Because clear is not a valid property for float.  Clear is a separate property itself.

Clear: left, right and none.
0

Featured Post

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Porbably easy CSS question about overlapping and offset images 21 26
Box Locations 6 16
How to show span when clicked on? 10 19
Hide cell in a table 2 9
CSS is a visual language used to classify objects and define rules about how they should be displayed. CSS skills aren’t restricted to developers anymore, there is a big benefit to having a basic understanding of the language, regardless of your occ…
Why do we like using grid based layouts in website design? Let's look at the live examples of websites and compare them to grid based WordPress themes.
In this tutorial viewers will learn how to embed an audio file in a webpage using HTML5. Ensure your DOCTYPE declaration is set to HTML5: : The declaration should display (CODE) HTML5 is supported by the most recent versions of all major browsers…
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.

776 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