473,898 Members | 4,077 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Div not centering in Firefox but fine in IE ?

Hi I'm new to group and I'm having an issue with a page I'm doing for
an Artist firend. This is my first foray into stylesheets.

here's the problem: I've got a dive I would like centered. I use the
code below to created a div that's centerd on the page. It works in IE
bit does not work in Firefox Mozilla etc.

here's the code

body{
text-align:center;
font-color:#ffffff;
background-image:URL(gothc lub.jpg);
}
div{
text-align:center;
padding:5px;
padding-top:10px;
margin-top:10px;
margin:left:20% ;
width:60%;
color:sienna;
background-color:#330000;
border:1px #82543d solid
}

Any help will be appreciated.

Dave

Jul 21 '05 #1
9 52830
da************* @gmail.com wrote:
Hi I'm new to group and I'm having an issue with a page I'm doing for
an Artist firend. This is my first foray into stylesheets.

here's the problem: I've got a dive I would like centered. I use the
code below to created a div that's centerd on the page. It works in IE
bit does not work in Firefox Mozilla etc.

here's the code

body{
text-align:center;
font-color:#ffffff;
background-image:URL(gothc lub.jpg);
}


To centre a block you are supposed to set margin-left and margin-right
to auto, but IE doesn't honour this, so you have to use
text-align:center to make IE happy, plus margin-left:auto;
margin-right:auto for the standards compliant browsers.
Jul 21 '05 #2
Why am I not suprised IE is not compliant ? Well thanks for the tip it
worked like a champ !!

Dave

Jul 21 '05 #3
C A Upsdell > wrote:

To centre a block you are supposed to set margin-left and margin-right
to auto, but IE doesn't honour this,
IE6 in standards mode does, for sure.
text-align:center to make IE happy,


More specifically, IE5.x or IE6 in quirks mode (which you shouldn't be
triggering, anyway).

--
Reply email address is a bottomless spam bucket.
Please reply to the group so everyone can share.
Jul 21 '05 #4
Please elaborate on standards mode and quirks mode ? Especially what
one does to trigger quirks mode ?
In the meantime I'll STFW regarding these modes.

Dave

Jul 21 '05 #5
da************* @gmail.com wrote:
Please elaborate on standards mode and quirks mode?
http://dorward.me.uk/www/centre/#ie
http://gutfeldt.ch/matthias/articles/doctypeswitch.html
Especially what one does to trigger quirks mode ?


You don't trigger quirks mode, its the default. You trigger standards mode.

--
David Dorward <http://blog.dorward.me .uk/> <http://dorward.me.uk/>
Home is where the ~/.bashrc is
Jul 21 '05 #6
Thanks

Jul 21 '05 #7
da************* @gmail.com wrote:
Hi I'm new to group and I'm having an issue with a page I'm doing for
an Artist firend. This is my first foray into stylesheets.

here's the problem: I've got a dive I would like centered. I use the
code below to created a div that's centerd on the page. It works in IE
bit does not work in Firefox Mozilla etc.

here's the code

body{
text-align:center;
font-color:#ffffff;
background-image:URL(gothc lub.jpg);
}
div{
text-align:center;
padding:5px;
padding-top:10px;
margin-top:10px;
margin:left:20% ;
width:60%;
color:sienna;
background-color:#330000;
border:1px #82543d solid
}

Any help will be appreciated.

Dave


I would use shorthand on some your properties as well:

------------------------------------------------------
body {
margin-left:auto;
margin-right:auto;
width:50%;
text-align:center;
background:tran sparent URL(gothclub.jp g);
}

div {
text-align:center;
padding:10px 5px 5px 5px;
margin:10px 20% 0;
width:60%;
color:#960; /* Try to use shorthand #960 */
background:#300 none;
border:1px solid #853;
}
------------------------------------------------------

My 2 cents.

JL
Jul 21 '05 #8
Justin Lieb wrote:

I would use shorthand on some your properties as well:


By shorthand, you mean

border: thin solid black;

rather than

border-width:thin;
border-style:solid;
border-color:black;

right?

I'm curious: other than simplifying the coding, is there any performance or
other benefit to working this way?

--
Tony Garcia
http://www.dslextreme.com/~tony23/
Jul 21 '05 #9
On Tue, 14 Jun 2005, Tony wrote:
Justin Lieb wrote:

I would use shorthand on some your properties as well:
By shorthand, you mean

border: thin solid black;

rather than

border-width:thin;
border-style:solid;
border-color:black;

right?


there's also border-top-width, border-right-width, and so on, if you
want/need to spell it out in every tedious detail... see e.g the
navigation area at http://www.w3.org/TR/CSS21/box.html
I'm curious: other than simplifying the coding,


I'd see that as a benefit: smaller CSS files, less to transfer over
the net, in theory less to go wrong.

Early browser implementations of CSS were rather buggy in this area,
and some of us got accustomed to specifying both forms, in the hope
that this or that browser would grok at least one of them. But by now
that sort of nonsense should be finished, and those who are using old
buggy browsers have surely got accustomed to less than ideal results
on other web sites, and with a reasonable attitude to flexible design
(which IMHO probably means using float in preference to absolute or
fixed positioning, where bugs can all too easily result in overlapping
areas), they should at least get a usable page, even if its cosmetics
leave something to be desired.

If all else fails they can disable (author) stylesheets, one way or
another.

imho and ymmv, anyway.
Jul 21 '05 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
11211
by: Duane Lambe | last post by:
Hi - just a quick question, I hope it's simple enough that a visual example isn't required. I have an internal site, everything's the way I want it, but there's an anomoly in both Opera and Firefox, which doesn't exist in IE (surprise). Essentially, it's a div being margin:auto-d on the page. #container { padding: 0;
15
13521
by: red | last post by:
How do I center two side by side divs ? I've been writing css pages for a while but there's one thing tha still eludes me. I can center a div with margin auto. I can place two divs side by side with float. But I can't center two side by side divs. If I float them and give them auto margins, the auto margins are ignored. If I wrap the two floated divs in another div, the two divs have no
3
6130
by: yawnmoth | last post by:
I'm trying to center list elements in a webpage I'm working on, and setting margin-left to auto for ol (or ul) seems to prevent the number (or bullet) from displaying in IE6 (strict mode) and Opera7 (it works fine in Firefox). Any ideas as to why and what I might do to fix it? I've set up a little demonstration of the problem here: http://www.frostjedi.com/terra/dev/test.html It's set up to render in quirks mode to demonstrate that it...
6
1400
by: Simon Wigzell | last post by:
I have the following funciton that centers my website content for any size window and will center it in real time as the window is expanded or shrunk. It is activated by a onresize="CenterIt();" in the body tag. Works fine for IE. How do I make it compatible with netscape and most browsers? Better yet, is there a good single source that explains how to write javascript to be compatible with all browsers? 766 and 435 are the width and...
3
4220
by: John Pote | last post by:
1. Horizontal centering a <divin browser window. The current trend seems to be to place page content in a fixed width area in the middle of the browser window. How is this achieved? If I use a top level <divthen I can place it with CSS attribute 'left:', but this is a fixed offset. Is it possible to have a <divcentered in the browser window? 2. Verticle centering in <div>
3
3675
by: BT | last post by:
I have taken over the support of an existing webpage and I need to revise the page so that it is centered (left and right) on the screen instead of aligned on the left. I can do this easily, but there is a little JavaScript that doesn't work correctly after I center it. I have tried to realign the page with either <centertag or align="left" attribute, but the pictures displayed with the JavaScript get messed up with everything I've...
9
7283
by: Neal | last post by:
http://www.brassattackofspringfield.com/gigs.html CSS at http://www.brassattackofspringfield.com/default.css Opera and IE render caption as desired. Firefox does not. Why? And is there a fix?
11
2059
by: Cartoper | last post by:
Here is the code: http://cartoper.ueuo.com/centering.htm How do I get the big blue buttons to center themselves on Firefox and Safari on this web site? I know that the layout is a bit complex, but there is a reason for it, have a look at this site:
14
2547
by: issentia | last post by:
I'm working on this site: http://www.essenceofsoy.com/redesign/index2.html and I'm having a few problems with getting the layout exactly right. 1) When the menu items are rolled over, they cannot be clicked as links unless the mouse pointer is below the word. This happens in both Firefox and IE6. 2) In Firefox, the pink quote banner and two gray form boxes above and below the content aren't centered in the "content" div, and I can't...
0
11265
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10858
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10949
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10484
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9662
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
8036
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
1
4706
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
4296
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3306
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.