Beginner Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsOtherBeginner Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old August 21st, 2003, 12:29 PM
shokesy shokesy is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2002
Posts: 62 shokesy User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 46 m 42 sec
Reputation Power: 7
centering an image WITHIN a cell

i know this is basic...i've tried align..i've tried center...how on earth do you center an image withing a a cell table (i.e, between the td tags in a table)if the image is smaller than the cell, because by default it keeps aligned to the right?

is there a css way of doing this so that images are centered in the middle of a cell in a table (meaning there is equal space on either side of an image within a cell) by default?

thanks folks.

Reply With Quote
  #2  
Old August 21st, 2003, 12:31 PM
shokesy shokesy is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2002
Posts: 62 shokesy User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 46 m 42 sec
Reputation Power: 7
to clarify, i know that td align = "center" works, but how can i do this css style so i dont have to have redundanct code for every td tag?

Reply With Quote
  #3  
Old August 22nd, 2003, 06:09 AM
sacrilege sacrilege is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Dec 2002
Location: Norwich, UK
Posts: 53 sacrilege User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 9 h 1 m 53 sec
Reputation Power: 6
For horizontal alignment use text-align: center; and for vertical alignment use vertical-align: center;.

Reply With Quote
  #4  
Old August 23rd, 2003, 08:56 PM
drgroove's Avatar
drgroove drgroove is offline
pushing envelopes, not pencils
Dev Shed God 2nd Plane (6000 - 6499 posts)
 
Join Date: Feb 2002
Posts: 6,225 drgroove User rank is First Lieutenant (10000 - 20000 Reputation Level)drgroove User rank is First Lieutenant (10000 - 20000 Reputation Level)drgroove User rank is First Lieutenant (10000 - 20000 Reputation Level)drgroove User rank is First Lieutenant (10000 - 20000 Reputation Level)drgroove User rank is First Lieutenant (10000 - 20000 Reputation Level)drgroove User rank is First Lieutenant (10000 - 20000 Reputation Level)drgroove User rank is First Lieutenant (10000 - 20000 Reputation Level)drgroove User rank is First Lieutenant (10000 - 20000 Reputation Level) 
Time spent in forums: 1 Day 4 h 44 m 44 sec
Reputation Power: 174
You can also simply specify the image alignment w/in the image tag itself:
PHP Code:
<img src='/images/img.gif' border='0' width='80' height='60' align='center' valign='middle' hspace='' vspace='' alt='my pic!' title='my pic!'
__________________
Give a person code, and they'll hack for a day; Teach them how to code, and they'll hack forever.
Analyze twice; hack once.
The world's first existential ITIL question: If a change is released into production without a ticket to track it,
was it actually released?


About DrGroove: ITIL-Certified IT Process Engineer - Enterprise Application Architect -
Freelance IT Journalist - Devshed Moderator - Funk Bassist Extraordinaire


Reply With Quote
  #5  
Old August 24th, 2003, 10:17 AM
shokesy shokesy is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2002
Posts: 62 shokesy User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 46 m 42 sec
Reputation Power: 7
Quote:
Originally posted by sacrilege
For horizontal alignment use text-align: center; and for vertical alignment use vertical-align: center;.


cool, that was something i was looking for, however with the "text-align:center" the image AND the text gets centered. I only want the image to be centered, and for the text to still be left aligned as default. Is there a css way to do this? (right now im resorting to tags within the html tag, but it seems redundant and messy.

Reply With Quote
  #6  
Old August 24th, 2003, 10:50 AM
computer's Avatar
computer computer is offline
echo $usertitle['computer'];
Dev Shed God 4th Plane (6500 - 6999 posts)
 
Join Date: Jan 2003
Location: UK
Posts: 6,675 computer User rank is Captain (20000 - 30000 Reputation Level)computer User rank is Captain (20000 - 30000 Reputation Level)computer User rank is Captain (20000 - 30000 Reputation Level)computer User rank is Captain (20000 - 30000 Reputation Level)computer User rank is Captain (20000 - 30000 Reputation Level)computer User rank is Captain (20000 - 30000 Reputation Level)computer User rank is Captain (20000 - 30000 Reputation Level)computer User rank is Captain (20000 - 30000 Reputation Level)computer User rank is Captain (20000 - 30000 Reputation Level) 
Time spent in forums: 4 Weeks 9 h 12 m 10 sec
Reputation Power: 219
Send a message via ICQ to computer
okay,

make a class called imagecenter and have it:

imagecenter{
text-align:center;
vertical-align:center;}

and in the image tag:

<img src="img.gif" alt="Piccie" width=50 height=50 class="imagecenter">

and delete what is in the td tag you put in above.

Reply With Quote
Reply

Viewing: Dev Shed ForumsOtherBeginner Programming > centering an image WITHIN a cell


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 4 hosted by Hostway
Stay green...Green IT