Greenguy's Board

Greenguy's Board (http://www.greenguysboard.com/board/index.php)
-   Programming & Scripting (http://www.greenguysboard.com/board/forumdisplay.php?f=15)
-   -   Centering div with HTML 4.01 Transitional (http://www.greenguysboard.com/board/showthread.php?t=57614)

LD 2010-05-25 10:08 AM

Centering div with HTML 4.01 Transitional
 
To center divs on a page, I usually use:
Code:

margin-right: auto;
margin-left: auto;

but this seems to only with HTML 1.0 transitional. Can you make it work with 4, or maybe just use 1.0 all the time or maye something else altogether....?

Cleo 2010-05-25 10:17 AM

I had a problem centering iframes recently using the code you posted. The solution was to give the item I was trying to center a fixed width instead of a percentage.

LD 2010-05-25 11:40 AM

Quote:

Originally Posted by Cleo (Post 482503)
I had a problem centering iframes recently using the code you posted. The solution was to give the item I was trying to center a fixed width instead of a percentage.

iframes behave in strange ways sometimes for me, and I also do a fixed width usually wider than the iframe and add this:
Code:

text-align: center;
to the div's properties.

But I was referring to centering the actual div, not the content within the div. Seems to behave differently in HTML 1.0 and HTML 4.0

bluebrit 2010-05-25 11:47 AM

the
tag was deprecated in HTML 4.0 so try using this

Cleo 2010-05-25 11:51 AM

Yeah it was the content within the div that I was talking about.

Despite using text-align: center; my iframe still wasn't centering. I did some Googling and found the suggestion to give my iframe a fixed width instead of a percent and it fixed it.

I still struggle with css but thought that maybe it would work with your issue too.

Just a guess but maybe
display:block;
margin-right:auto;
margin-left:auto;

Nymph 2010-05-25 11:56 AM

using


I use


of course you can use styling to the div tag too

Maj. Stress 2010-05-26 01:01 PM

Quote:

Originally Posted by bluebrit (Post 482523)
the
tag was deprecated in HTML 4.0 so try using this

It was? I can still validate pages at w3.org using it.
link

http://slut-fest.com/gay-twinks-fuck/

bluebrit 2010-05-26 03:32 PM

Quote:

Originally Posted by Maj. Stress (Post 482624)
It was? I can still validate pages at w3.org using it.
link

It has been deprecated in 4.01 transitional and frameset, take a look at the table in their own link below.

http://www.w3schools.com/tags/default.asp

Maj. Stress 2010-05-26 09:43 PM

Quote:

Originally Posted by bluebrit (Post 482628)
It has been deprecated in 4.01 transitional and frameset, take a look at the table in their own link below.

http://www.w3schools.com/tags/default.asp

Interesting that the validator does not flag it. I've had it flag the div align="center" before. |crazy|

Maj. Stress 2010-05-26 09:46 PM

Quote:

Originally Posted by Cleo (Post 482525)
Yeah it was the content within the div that I was talking about.

Despite using text-align: center; my iframe still wasn't centering. I did some Googling and found the suggestion to give my iframe a fixed width instead of a percent and it fixed it.

I still struggle with css but thought that maybe it would work with your issue too.

Just a guess but maybe
display:block;
margin-right:auto;
margin-left:auto;

I haven't tested it but that looks like it should work.


All times are GMT -4. The time now is 02:33 PM.

Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
© Greenguy Marketing Inc