Computing.Net > Forums > Web Development > horizontal align with css?

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to get for your free account now!

horizontal align with css?

Reply to Message Icon

Name: tImmaY
Date: July 7, 2004 at 00:34:37 Pacific
OS: Windows XP Pro SP1
CPU/Ram: AMD Athlon XP 2400+/512 m
Comment:

hey, i've done kind of a lot with CSS but i've never come across this, so i was wondering if there was a way that you could horizontally align something (like the information within a table data cell) in css? besides like padding-left and padding-right..?


Report Offensive Message For Removal

Sponsored Link
Ads by Google

Response Number 1
Name: jam14online
Date: July 7, 2004 at 07:54:35 Pacific
Reply:

For your specific example, you can use the text-align property to center the information in that cell.

The best method I have found is to make an element a percentage width, for example 65%. Then you can use the margin-left property and set it to 17.5%. This is half of what is left (100 - 65 = 35 / 2 = 17.5), i.e. enough to have an equal margin on each side.

I hope this helps,


James



Report Offensive Follow Up For Removal

Response Number 2
Name: andyhargreaves
Date: July 7, 2004 at 11:08:16 Pacific
Reply:

Hi

I use text-align: center in CSS and it works very well. Seems simpler to me than using margins.


Report Offensive Follow Up For Removal

Response Number 3
Name: tImmaY
Date: July 13, 2004 at 00:49:14 Pacific
Reply:

thanks james, thats a good idea.. i've used something similar to that to align tables right.

thanks andy but that doesn't quite accomplish what i was thinking to do..


Report Offensive Follow Up For Removal
Reply to Message Icon

Related Posts

See More







Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Web Development Forum Home


Sponsored links

Ads by Google


Results for: horizontal align with css?

firefox with css www.computing.net/answers/webdevel/firefox-with-css/765.html

CSS Relative Positioning www.computing.net/answers/webdevel/css-relative-positioning/2265.html

Righ align a button w/CSS www.computing.net/answers/webdevel/righ-align-a-button-wcss/2975.html