473,413 Members | 2,058 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,413 software developers and data experts.

How to center a division in another one?

I want to center a division but I can't! It works only in Internet
Explorer but it doesn't in Opera, Mozilla or Firefox...Here's the code:

<!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=iso-8859-1" />
<title></title>
<style type="text/css">
<!--
#body {
text-align: center;
width: 100%;
}
#main {
background-color: #0099FF;
width: 780px;
}
-->
</style>
</head>

<body>
<div id="body">
<div id="main">Content for id "body" Goes Here</div>
</div>
</body>
</html>

Thanks,

--

Kerberos.

http://www.opera.com
http://www.freebsd.org
http://www.osresources.com
http://exodus.jabberstudio.org
Jul 21 '05 #1
7 6019
Kerberos wrote:
I want to center a division but I can't!


#body {
width: 100%;
}
#main {
background-color: #0099FF;
width: 780px;
margin-left: auto;
margin-right: auto;
}

780px fixed width, eh? Tut-tut.

--
Mark.
http://tranchant.plus.com/
Jul 21 '05 #2
Em Thu, 02 Dec 2004 14:41:28 +0000, Mark Tranchant
<ma**@tranchant.plus.com> escreveu:
Kerberos wrote:
> I want to center a division but I can't!
#body {
width: 100%;
}
#main {
background-color: #0099FF;
width: 780px;
margin-left: auto;
margin-right: auto;
}

Thanks! It fixed it ;)

780px fixed width, eh? Tut-tut.

What do you mean? I chose it because the page has to be readable on an
800px screen, and the content can't scale.

--

Kerberos.

http://www.opera.com
http://www.freebsd.org
http://www.osresources.com
http://exodus.jabberstudio.org
Jul 21 '05 #3
On Thu, 02 Dec 2004 12:02:29 -0200, Kerberos <me@privacy.net> wrote:
I want to center a division...


<sigh>

#body {
margin: 0;
border: none;
padding: 0;
width: 100%;
}

#main {
margin-top: 2em;
margin-right: auto;
margin-bottom: 2em;
margin-left: auto;
border: solid 1px #000000;
padding: 0;
background-color: #0099FF;
color: #000000;
width: 78%;
}

--
Rex
Jul 21 '05 #4
Kerberos wrote:
Em Thu, 02 Dec 2004 14:41:28 +0000, Mark Tranchant
<ma**@tranchant.plus.com> escreveu:
780px fixed width, eh? Tut-tut.

What do you mean? I chose it because the page has to be readable on an
800px screen, and the content can't scale.


Content can't scale, eh? Tut-tut.

So you're deliberately excluding WebTV, handhelds and anyone running
less than 800px wide screens; and you're also forcing 800'ers to maximize.

Is there a reason the content can't scale (like large images) or is that
a design decision of yours?

--
Mark.
http://tranchant.plus.com/
Jul 21 '05 #5
Em Thu, 02 Dec 2004 15:28:55 +0000, Mark Tranchant
<ma**@tranchant.plus.com> escreveu:
Kerberos wrote:
Em Thu, 02 Dec 2004 14:41:28 +0000, Mark Tranchant
<ma**@tranchant.plus.com> escreveu:

780px fixed width, eh? Tut-tut.

What do you mean? I chose it because the page has to be readable on an
800px screen, and the content can't scale.


Content can't scale, eh? Tut-tut.

So you're deliberately excluding WebTV, handhelds and anyone running
less than 800px wide screens; and you're also forcing 800'ers to
maximize.

Is there a reason the content can't scale (like large images) or is that
a design decision of yours?


I know, but my boss wants a fixed content. I showed him several web sites
with 100% width, but he said he wants white margins when the screen is
larger than 800px :s He said having white pargins is a trend that we have
to follow because it add clarity, but I don't agree.

--

Kerberos.

http://www.opera.com
http://www.freebsd.org
http://www.osresources.com
http://exodus.jabberstudio.org
Jul 21 '05 #6
Kerberos wrote:
I know, but my boss wants a fixed content. I showed him several web
sites with 100% width, but he said he wants white margins when the
screen is larger than 800px :s He said having white pargins is a trend
that we have to follow because it add clarity, but I don't agree.


Show him his page on a 1920px wide 24" widescreen monitor:

| | content | |
Side margins are fine, but there's no reason why the main content needs
to be pixel-sized. Size the margins in % and use max-width (not IE,
unfortunately) to constrain line length.

Good luck in getting that 24" monitor on expenses.

--
Mark.
http://tranchant.plus.com/
Jul 21 '05 #7
in comp.infosystems.www.authoring.stylesheets, Kerberos wrote:
I know, but my boss wants a fixed content.
Really?
I showed him several web sites with 100% width,
Not necessarily good idea. Better would have been to ask what page he
uses most, and then if that was fixed width, tell how it would be better
it it wasn't fixed width.
but he said he wants white margins when the screen is
larger than 800px :s
Well, that does not require fixed design. That is limiting width. Much
better than fixed pixel width, but still not very sencible.

And why he has this stupid idea of 800px? Why don't you make it em based
so that it will be about 800px on IE default font size?
He said having white pargins is a trend that we have
to follow because it add clarity, but I don't agree.


It actually is sometimes good idea to foolow trends. But if it was trend
to tell
--
Lauri Raittila <http://www.iki.fi/lr> <http://www.iki.fi/zwak/fonts>
Jul 21 '05 #8

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

Similar topics

2
by: Sebastian Haase | last post by:
Hi, I'm interested in having more people in our lab using numarray/NumPy instead of MatLab. For that I have put together a couple useful modules and written many myself. But then I got reminded of...
3
by: Unknown User | last post by:
Here's a new web site: http://www.auriance.com/clientes/cc/ Do you see the 4 squares at the bottom? They're a list that I want to be centered vertically inside the containing division. I tried...
5
by: Unknown User | last post by:
Here's a page that is centered in all browsers minus in IE 5.5: http://www.fala-brasil.com/test/ I used: #main { margin: 0 auto; width: 760px; }
24
by: Teis Draiby | last post by:
In .NET, can I be sure that the result of a division between two integers always is truncated rather that rounded to nearest? Example: 99 / 50 = 1 regards, Teis
2
by: Steve Miller | last post by:
hello... i am a 'user' of access, meaning, i import excel files, join, and merge....that's about the extent of my expertise with ms-access. my boss wants me to create an access application that...
17
by: seb.haase | last post by:
Hi, Is it true that that "Python 3000" is dead ? Honestly I think that e.g. changing 5/2 to be 2.5 (instead of 2) would just break to much code :-( On the otherhand I'm using Python as "Matlab...
94
by: krypto.wizard | last post by:
Last month I appeared for an interview with EA sports and they asked me this question. How would you divide a number by 7 without using division operator ? I did by doing a subtraction and...
16
by: spl | last post by:
To increase the performance, how to change the / operator with bitwise operators? for ex: 25/5, 225/25 or 25/3 or any division, but I am not bothered of any remainder.
5
Jezternz
by: Jezternz | last post by:
Okay, Basicly I want to center a division(horizontally), the only catch is the division has position:fixed (or relative if need be). The division's width is dynamic. Things that dont work (at...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
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,...
0
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...
0
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...
0
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,...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

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.