Go Back   CodingForums.com > :: Client side development > HTML & CSS

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 08-22-2009, 02:59 PM   PM User | #1
Gabby7
New Coder

 
Join Date: Jul 2009
Location: USA
Posts: 24
Thanks: 13
Thanked 0 Times in 0 Posts
Gabby7 is an unknown quantity at this point
Centering Issues

Hello+ I am doing a 'proof of concept' page using Dreamweaver 8. I am trying to get everything to center on the page no matter what the screen resolution is. Is this possible? I am having no luck using the following code:

Code:
<div align="center"><img src="images/msbanner.png" width="813" height="116" /></div>

<div align="center"><img src="beginningwebstuff/snarling tiger.jpg" width="468" height="478" /></div>
I have tried using the <center><img src="..." /></center> and no luck.
I have tried using the <div style="text-align: center;"><img src="..." /></div>
I have tried using the <align=center><img src="..." /></align>

I test using EI8, Firefox, & Netscape browsers. Does using Layers have anything to do with things not centering in the browser? Thank you in advance for any guidance on this.
Gabby7 is offline   Reply With Quote
Old 08-22-2009, 03:25 PM   PM User | #2
Scriptet
Regular Coder

 
Join Date: Apr 2008
Posts: 685
Thanks: 15
Thanked 105 Times in 104 Posts
Scriptet is on a distinguished road
adding align="center" is depreceated as is <center> as there effects can be re-created in CSS.

To center any DIV with a set width you simply use margin: 0 auto;
<div style="width: 812px; margin: 0 auto;">
<img src="images/msbanner.png" width="813" height="116" />
</div>

Note I add the CSS inline, it's best to give your DIV a class or ID and refer to it from an external stylesheet like:

<div class="myclassname">
<img src="images/msbanner.png" width="813" height="116" />
</div>


Then inside a css stylesheet you'd add:

.myclassname { width:813px; margin:0 auto; }
Scriptet is offline   Reply With Quote
Users who have thanked Scriptet for this post:
Gabby7 (08-27-2009)
Old 08-27-2009, 09:14 PM   PM User | #3
Gabby7
New Coder

 
Join Date: Jul 2009
Location: USA
Posts: 24
Thanks: 13
Thanked 0 Times in 0 Posts
Gabby7 is an unknown quantity at this point
Thank you

Thank you for the information - I see what I was missing before! Thank you!
Gabby7 is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 06:57 AM.


Advertisement
Log in to turn off these ads.