473,728 Members | 1,924 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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:70 0px;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:70 0px;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 1580
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:70 0px;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:70 0px;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:70 0px; background-color:blue;
margin-left:auto; margin-right:auto;">
*********TEXT*G oes*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:70 0px;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:70 0px;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.co m> 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.co m> 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:70 0px;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:70 0px;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:70 0px;background-color:blue;marg in-left:auto;margi n-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
7504
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 figure out how to get it to centet vertically. Any ideas? Ron Bott
3
3085
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 header/banner I'm trying to center the text vertically and horizontally to the right of the image on the left. As you can see, I've got the vertical part, I just can't get the horizontal part to go along with it. Any ideas?
6
2034
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 is at http://www.up-2-d8.de/menu.html Can you please take a look and see whether you can find anything I am doing wrong?!
2
1886
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 have two problems...It is the difference between IE and FF.. Problem #1.
3
6569
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 that didn't work. Of course I could put the DIV into a one-cell table and use the td's align and vertical-align attributes, but let's assume I don't want to
3
4209
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>
5
4822
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 doing this demo with tables. The main problems are the vertical centering of the info area, and of the text inside the squares.
2
1506
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 the browser window, such that the image will always stay glued to the bottom of the browser window no matter how big it is. Cool. But here's the catch. I'd really like to have a solid, 10px, black border around the whole affair -- you know,...
18
1383
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
2287
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 rows are centering their data. however, the row with three columns, each with images (myimages1-3) are not centering with the rest of the table. Any idea why? Thanks in advance!
0
8904
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9424
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
9277
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...
0
9135
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
8133
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...
0
6013
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4524
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
3236
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
3
2161
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.