473,386 Members | 1,748 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,386 software developers and data experts.

Centering a fixed with Div in the browser.

CES
All,

I'm sorry for the 2nd stupid question but... I'm trying to fix all of the issues I've had in the past. In the past I've resorted to using a table with the align attributed set to center as the container for the div that I want centered. As follows:

<table align="center">
<tr>
<td>
<div style="width:700px;background-color:Blue;">
TEXT Goes hear
</div>
</td>
</tr>
</table>

I've tried the following, with other variations, but while IE displays the div as I intended, Firefox does not center the div as intended it left aligns it.

<div style="text-align:center;">
<div style="width:700px;background-color:Blue;">
TEXT Goes hear
</div>
</div>

Any help on this would be greatly appreciated. Thanks in advance. - CES
Nov 23 '05 #1
4 1568
CES wrote:
All,

I'm sorry for the 2nd stupid question but... I'm trying to fix all of the
issues I've had in the past. In the past I've resorted to using a table
with the align attributed set to center as the container for the div that
I want centered. As follows:

<table align="center">
<tr>
<td>
<div style="width:700px;background-color:Blue;">
TEXT Goes hear
</div>
</td>
</tr>
</table>

I've tried the following, with other variations, but while IE displays the
div as I intended, Firefox does not center the div as intended it left
aligns it.

<div style="text-align:center;">
<div style="width:700px;background-color:Blue;">
TEXT Goes hear
</div>
</div>

Any help on this would be greatly appreciated. Thanks in advance. - CES


This seems to work for me, though I will not vouch for the "political
correctness" of the method:
...............................
<div style="text-align:center;">
*****<div style="width:700px; background-color:blue;
margin-left:auto; margin-right:auto;">
*********TEXT*Goes*hear
*****</div>
</div>

--

Greg Heilers
Registered Linux user #328317 - SlackWare 10.1 (2.6.10)
.....

As far as anyone knows we're a nice, normal family.

-- Homer Simpson
There's No Disgrace Like Home

Nov 23 '05 #2
CES a écrit :
All,

I'm sorry for the 2nd stupid question but... I'm trying to fix all of
the issues I've had in the past. In the past I've resorted to using a
table with the align attributed set to center as the container for the
div that I want centered. As follows:

<table align="center">
<tr>
<td>
<div style="width:700px;background-color:Blue;">
TEXT Goes hear
</div>
</td>
</tr>
</table>

I've tried the following, with other variations, but while IE displays
the div as I intended, Firefox does not center the div as intended it
left aligns it.

<div style="text-align:center;">
<div style="width:700px;background-color:Blue;">
TEXT Goes hear
</div>
</div>


As I understand what you are looking for (it's not clear), you want to
center the inline element, not center the block-level element within its
own container. I must say I'm not sure of what you want to center.

<div style="text-align:center; width:700px; background-color:
blue;">TEXT Goes hear</div>

Try this demo:

http://www.gtalbot.org/NvuSection/Nv...Alignment.html

Gérard
--
remove blah to email me
Nov 23 '05 #3
CES <no**@none.com> wrote:
I've tried the following, with other variations, but while IE displays the div as I intended, Firefox does not center the div as intended it left aligns it.


http://dorward.me.uk/www/centre/

--
Spartanicus
Nov 23 '05 #4
"CES" <no**@none.com> wrote in message
news:4%*****************@news-wrt-01.rdc-nyc.rr.com...
All,

I'm sorry for the 2nd stupid question but... I'm trying to fix all of the
issues I've had in the past. In the past I've resorted to using a table
with the align attributed set to center as the container for the div that
I want centered. As follows:

<table align="center">
<tr>
<td>
<div style="width:700px;background-color:Blue;">
TEXT Goes hear
</div>
</td>
</tr>
</table>

I've tried the following, with other variations, but while IE displays the
div as I intended, Firefox does not center the div as intended it left
aligns it.

<div style="text-align:center;">
<div style="width:700px;background-color:Blue;">
TEXT Goes hear
</div>
</div>

Any help on this would be greatly appreciated. Thanks in advance. - CES


Read up on CSS a bit more - the answer is actually rather easy to find:

IE renders incorrectly and centers the DIV. A DIV is a block-level element,
and should not be centered by use of "text-align". Rather, you center a DIV
by adjusting the margins. Try:

<div style="text-align:center;"> <!-- Keep this here for IE -->
<div
style="width:700px;background-color:blue;margin-left:auto;margin-right:auto;">
Text goes here
</div>
</div>
Also, try a little more googling - and check out the CSS tutorial at
W3schools.com: http://www.w3schools.com/css/default.asp
Nov 23 '05 #5

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

Similar topics

1
by: Ron Bott | last post by:
I have a fixed size <div> I would like to display in the center of a browser window. To get the horizontal alignment is no problem using 'margin-left: auto' and 'margin-right: auto' but I cannot...
3
by: Wayfarer | last post by:
I *HAVE* Googled the hell out of it, but there's nothing I can understand (in words of one syllable or less) that works for me. If you go to http://www.journeys.ws/layout.html, on the...
6
by: Axel Siebenwirth | last post by:
Hi, as described at http://www.quirksmode.org/css/centering.html, I try to do to centering with my site. I did exactly as told on that page but it only seems to center horizontally. My site...
2
by: Gnolen | last post by:
Hi again, Last time my server was down(as for many others I have heard), but now it is online again! I would be really really happy if someone could take a look at my problem a bit. I now...
3
by: Robert Latest | last post by:
Hello, me again. This time I'd like to align a DIV both horizontally and vertically centered within a larger DIV. The only alignment-relevant CSS property I could think of was text-align, and...
3
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...
5
by: Markus Ernst | last post by:
Hello This is a test example: http://www.markusernst.ch/anthracite/ http://www.markusernst.ch/anthracite/living_divani.html After googling and experimenting for several hours, I ended up...
2
by: texvanwinkle | last post by:
"WITH a border" being the defining issue. Here's the deal: I'm new to CSS, but I've managed so far to center a single line of links at the top of my home page and center an image on the bottom of...
18
by: prophet | last post by:
I have a page that uses 3 frames. 1 left 1 top and 1 main how do I center the page so that it is in the middle?
1
by: =?Utf-8?B?ZnJhbmt5?= | last post by:
Hello, I've created a table that has two rows that are span across three columns. The third row has three columns, each with an image. The last row is also span accross three columns. The span...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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
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...

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.