Jump to content
  • Advertisement
Sign in to follow this  
Jarrod1937

[web] how to center div?

This topic is 4409 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Advertisement
you have to set the margin like this:

<div style="width:[width here]; margin: 0 auto;></div>

you can change the 0 to whatever you want. (Not really HTML but CSS is your friend [smile])

Share this post


Link to post
Share on other sites
Quote:
Original post by capn_midnight

<div align="center">blah</div>
What browser are you using? When I do that in FireFox the div stays left-aligned and the text inside is centered.

Share this post


Link to post
Share on other sites
Quote:
Original post by DigiDude
Quote:
Original post by capn_midnight

<div align="center">blah</div>
What browser are you using? When I do that in FireFox the div stays left-aligned and the text inside is centered.


That's what it *should* do. The margin: auto is the correct way to do it, but IIRC Internet Explorer doen't like it (no surprise here...)

Share this post


Link to post
Share on other sites
well after further use, the div now seems to be aligning itself to the left. using capn_midnights example. any more help?
edit: yeah, it behaves like DigiDude said. i'll try your example digidude.

Share this post


Link to post
Share on other sites
Quote:
Original post by Rob Loach
And yes, <div align="center">blah</div> it is.

No no, that centers the content of the div.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!