|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
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. |
|
#2
|
|||
|
|||
|
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?
|
|
#3
|
|||
|
|||
|
For horizontal alignment use text-align: center; and for vertical alignment use vertical-align: center;.
|
|
#4
|
||||
|
||||
|
You can also simply specify the image alignment w/in the image tag itself:
PHP Code:
__________________
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 |
|
#5
|
|||
|
|||
|
Quote:
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. |
|
#6
|
||||
|
||||
|
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. |
![]() |
| Viewing: Dev Shed Forums > Other > Beginner Programming > centering an image WITHIN a cell |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|