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

Center a (dynamic width)Division with fixed position

Jezternz
145 100+
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 least through my testing):
margin: 0 auto; << Only applies to Static objects
left: 50%;width (x)px; << Only applies to objects with a constant width

It works in IE by using margin: 0 auto; (which is very odd to me, but it works). Firefox and Chrome arnt so forgiving.

Something tells me there is no way I can do this (without javascript at least) in FF/CH.

Thanks, Josh
Jun 9 '09 #1
5 5132
Death Slaught
1,137 1GB
Have you tried placing the division in another division and then giving the parent division the text-align:center style?

Thanks,
{\_/}
(' . ')
(")[DEATH](")
(")(")
Jun 9 '09 #2
Dormilich
8,658 Expert Mod 8TB
@Jezternz
as far as I know IE doesn't support position: fixed.
Jun 9 '09 #3
drhowarddrfine
7,435 Expert 4TB
'fixed' does not work in IE6 and less, is buggy in IE7 but works in IE8.

Never, ever look to IE as a reference for how or when things work. It's the worst browser on the planet and 11 years behind all other browsers in modern standards and practices.

Always, always use a modern browser (not any version of IE) to test your markup first.

The web developer's mantra: "If it works in IE, but not the other browsers, my markup is wrong."
Jun 9 '09 #4
Jezternz
145 100+
Thanks for replies.
I was under the impression " text-align:center " Only works in IE and not the W3C standard browsers.
@drhowarddrfine
Ahhh ok, I have been testing in IE7
@drhowarddrfine
I always test my markup in FF/CH/IE7
@drhowarddrfine
I apologize, what my question is really is "what would be the correct markup (if possible)" or "what would be an alternative" (since ie6 would not work) :(
Jun 9 '09 #5
drhowarddrfine
7,435 Expert 4TB
@Jezternz
IE7 is not a modern browser. Nor is IE8. Always test in any other browser first. Then check to see if/when IE screws things up. You should never use IE as a reference for how things should work is the point. It can't be trusted to do anything right.

It might do you better to use Firefox, then Safari, then Chrome or Opera, then IE.

It will be a lot easier to help you if we had a link or the complete markup to work with.
Jun 10 '09 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

20
by: Terry | last post by:
I'm trying to have two divs side-by-side, each taking up 50% of the body. Sounds simple enough, right? http://novodom.net/div.html The code validates as XHTML 1.1 Strict. Looks fine in Firefox,...
7
by: Petesman | last post by:
I am trying to make a prompt that will ask the user for some input... If I just use var input = prompt("dafa") everything works fine but the box is put in the top left corner of the window. I need...
2
by: Jonathan Carmichael | last post by:
I'm trying to create a fixed, no-repeat, centered background image using an external css. Everything works great until I add background-attachment: fixed then it just doesn't show the image...
3
by: Kenneth | last post by:
Hi, In a webform I have a datagrid in a certain position using gridlayout. <asp:DataGrid id="dgrdSkada" style="Z-INDEX: 107; LEFT: 16px; POSITION: absolute; TOP: 200px" runat="server"...
5
by: John Smith | last post by:
Here is my HTML table formatting code. <table border="1" width="100%"> <tr width = "100%"> <td width="33%">11asdhagdshaskgashjgahjgadhjgdjshdgasjdgajdgadjhgdgahjdgadhjsgad
1
by: HeroinNO.4 | last post by:
Hello guys, sorry for my last version has a little "feature"(MS always call his bug "feature"), and now I fixed it and show the source to you all ! Just as the last version, copy the code below and...
2
Jezternz
by: Jezternz | last post by:
Hey, there is something I have wanted to know for a while, but I have never been sure whether it is possible in html/css. Basicly I want to have 3 divisions. html eg: <div id="top">a</div>...
1
by: dev56 | last post by:
I Have a table tag I want it's width to be as I set it even when content is larger. I used the property style="table-layout:fixed" but then the com=ntent is cut, while I want the cell to include the...
1
by: saiskarur | last post by:
hai i am satheesh i am a student, actually i was make a one web page, here it contain one parent div, and the parent div contain three div, how can i align center for the children div code...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work

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.