University Web Developers

University Web Developers

I am having the hardest time making margin settings stick in Firefox.

I have used :
div#container {
margin-left: auto;
margin-right: auto;
width: XXpx;
}

and it just doesn't seem to work.

I have also tried setting my margins to zero. I have other isssues with CSS but this is the one that is bugging me the most right now. I have been forced to do some very ugly things to get my margins to act right.

Can anyone help?!?

Views: 27

Replies to This Discussion

Are you trying to centre #container? Try making it's parent element's position either relative or absolute.
Yep, I will post the problem in the next couple of days so that we can look at it together. As you probably seen in the other reply I stuck it in a to show properly. I know - I know.
can you share a link to the page? The problem is probably with the elements around it, more than the code you have. Firefox is usually pretty easy to work with, so it should be very simple to fix.
I have torn the page into pieces. I will try to recreate the problem in the next couple of days. I did something VERY ugly to get it ready to show... are you ready.... I stuck it in a
of a table. I will bring it out of the table and show you guys - thanks for all the help
My work around is having to put both for IE and Firefox. For Firefox I put "!important" after the px and before the ; I found this solution out on the web.

padding-top: 6px;
padding-top: 8px!important;
What does the !important tell the browser?
it says hey do this nomartter what. Kathy's code cancels each other.
Can you say more what you need to do? margin-left/right: auto; is used to center the element. However you need to define a width, unless you set the display to block. By default a div is width:100%. One thing to try is to remove the div from above. Sometimes the browser thinks this says container is a child. So it is looking for
<div>
<div id="container">
</div>
</div>
hi shere hicks...what aer you trying to fix? can you ftp your file so that we could you help you to re-align whatever problems do you have?
To aggregate some of the comments already made, and to add a little bit of information I've found to be helpful in my own use of "margin: auto", here are my thoughts:
1) The div#container has to be a block-level element. If any of your CSS anywhere switched your divs to inline, inline-block or whatever, you will need to explicitly redeclare the fact that div#container should be block
2) An automatic margin only works if you define a specific width for the div. I'm assuming you have done so, since your example has "XXpx" set as the width (I'm hoping you didn't actually use "XX" in your CSS declaration).
3) It is helpful to declare "text-align: center" for the parent node of div#container, then redeclare "text-align: left" for the div#container. That is the only way I've been able to get my container div centered consistently within IE (the auto margin worked just fine for Firefox, but never worked in IE).
4) Make sure you don't have any floats that might be pushing your container in any direction. Floats that are not cleared properly will mess up the margins of your div#container.
5) Just to clarify - you do want div#container to be centered on the page, not something found inside of div#container, right?
To center a div do this:

#container {margin: 0 auto; width:xx px;}

or

#container {margin-left: 0 auto; margin-right: 0 auto; width:xx px;}
could you supply a link to the page? As others have stated it's not entirely clear what your issue is from the code you posted.

The code you have supplied will 100% give you a centered div in the browser window (again as others have said assuming you actually assigned values to xx in the width). Weirdly firefox is one of the browsers that absolutely shouldn't give you any problems on this front (unlike ie6 which benefits from the text-align 'hack' - I say hack but actually the code still validates).

Again as others have mentioned there might be some floating divs causing issues? Try adding clear:both; and see if that changes anything.

RSS

Elsewhere

Latest Activity

Profile IconDoug Kern, Melisa T Haggerty, Jeff Hilyard and 32 more joined University Web Developers
11 hours ago
Colleen Brennan-Barry posted a discussion

Call for 2014 HighEdWeb Regional Conference Hosts

Have you attended one of HighEdWeb’s regional conferences, or heard the great buzz about the regionals, and thought that your institution would be an ideal future conference host? Then we invite you:Submit a proposal by June 30 to host a 2014 HighEdWeb regional.“Planning a regional event, while work-intensive, gives both planning committee members and conference attendees an incredible…See More
16 hours ago
Anne Swinton joined Stewart Foss's group
16 hours ago
Anne Swinton commented on Brent Hoard's group Sitecore
"We are about to implement Sitecore in the next few months, so I'm hoping to find some useful info here for our transition. We are currently in Ironpoint/Active CMS."
16 hours ago
Anne Swinton joined Brent Hoard's group
Thumbnail

Sitecore

For users of the Sitecore CMS
16 hours ago
Erik Hagen replied to Chris Lewinski's discussion Success metrics for web CMS implementation?
"As Annette said, it depends on why you're doing it. What are the problems that need to be solved, and what are the outcomes that can be measured? I'm planning to switch to a CMS from not having one this coming year, and most of our issues…"
20 hours ago
Liz Snow commented on Debbie's blog post Web CMS evaluations project
"Later this year, we plan to re-evaluate our CMS also.  I would be interested in material you were able to gather to support you such as the samples from Holly and/or the information from Miz."
20 hours ago
Erik Hagen replied to Kathy Jensen's discussion Content: Header and Footer
"For our global header nav, I've been tracking every click as an event in Google Analytics for several months. It's pretty clear now which links are popular and which are being ignored. I also use Crazy Egg to see clicks on the current…"
21 hours ago
Peter Sawyer left a comment for richeleine gandon
"Hi Richeleine,  Looks like your account is being used to send out spam. If you check your comments, your account has left the same comment for many others. Also, your website throws a 404.  Here is something good to think about…"
21 hours ago
Mark Greenfield's video was featured

HighEdWeb '13 Annual Conference - Buffalo Style

Much like #marks911 the HighEdWeb Annual conference is a beautiful thing to behold. http://2013.highedweb.org Get to Buffalo this October to network, share, ...
21 hours ago
Mark Greenfield posted a video

HighEdWeb '13 Annual Conference - Buffalo Style

Much like #marks911 the HighEdWeb Annual conference is a beautiful thing to behold. http://2013.highedweb.org Get to Buffalo this October to network, share, ...
22 hours ago
Daniel Bashaw replied to Daniel Bashaw's discussion What tech do you use for remote presentations?
"Thanks – I've also heard mention of Adobe Connect as a tool the #PSEWEB conference organizer has used successfully in the past -- I'll check it out as an option."
22 hours ago
richeleine gandon left a comment for Jesse Racine
"Hello Dear, I will like to get acquainted with You, I have something Special to share with You, Contact me via email: richeleine.gandon@live.comMiss Richeleine."
yesterday
richeleine gandon left a comment for Géna Thompson
"Hello Dear, I will like to get acquainted with You, I have something Special to share with You, Contact me via email: richeleine.gandon@live.comMiss Richeleine."
yesterday
richeleine gandon left a comment for Ed Hillis
"Hello Dear, I will like to get acquainted with You, I have something Special to share with You, Contact me via email: richeleine.gandon@live.comMiss Richeleine."
yesterday
richeleine gandon left a comment for Erin Leavitt
"Hello Dear, I will like to get acquainted with You, I have something Special to share with You, Contact me via email: richeleine.gandon@live.comMiss Richeleine."
yesterday
richeleine gandon left a comment for Sara Leavitt
"Hello Dear, I will like to get acquainted with You, I have something Special to share with You, Contact me via email: richeleine.gandon@live.comMiss Richeleine."
yesterday
richeleine gandon left a comment for Brian Rogers
"Hello Dear, I will like to get acquainted with You, I have something Special to share with You, Contact me via email: richeleine.gandon@live.comMiss Richeleine."
yesterday
richeleine gandon left a comment for Sheila Lefor
"Hello Dear, I will like to get acquainted with You, I have something Special to share with You, Contact me via email: richeleine.gandon@live.comMiss Richeleine."
yesterday
richeleine gandon left a comment for Max Bronsema
"Hello Dear, I will like to get acquainted with You, I have something Special to share with You, Contact me via email: richeleine.gandon@live.comMiss Richeleine."
yesterday

UWEBD has been in existence for more than 10 years and is the very best email discussion list on the Internet, in any industry, on any topic

About

© 2013   Created by Mark Greenfield.

Badges  |  Report an Issue  |  Terms of Service