CSS Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsWeb DesignCSS Help

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 February 12th, 2004, 09:09 PM
Jarrett Green Jarrett Green is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Dec 2003
Posts: 85 Jarrett Green User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 7 h 40 m 11 sec
Reputation Power: 5
Send a message via AIM to Jarrett Green
Exclamation CSS Vertical Align Question

I have a div with this ID:

#sml_image_container {
margin: 2px;
padding: 2px;
height: 70px;
width: 70px;
border: 1px dashed #333333;
font-family: Arial, Helvetica, sans-serif;
font-size: 10px;
color: #FFFFFF;
font-weight: bold;
vertical-align: middle;
}

I'd like to have a div work like a cell in a table that is 70px by 70px - with the text centered both horiz. and vert.. But I can't get it. Is the above the correct use of the "vertical-align"?

I need the CSS equivilent to <td align="center" valign="middle"> in a DIV.

Reply With Quote
  #2  
Old February 12th, 2004, 10:22 PM
brianellisrules brianellisrules is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Feb 2004
Posts: 36 brianellisrules User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 4 h 46 m 38 sec
Reputation Power: 5
vertical-align applies only to table cells.


can you show us an example of what you have and what you're trying to do and maybe we can come up with a work-around?

Reply With Quote
  #3  
Old February 12th, 2004, 10:27 PM
Jarrett Green Jarrett Green is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Dec 2003
Posts: 85 Jarrett Green User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 7 h 40 m 11 sec
Reputation Power: 5
Send a message via AIM to Jarrett Green
I think. I have a div. It is 70px by 70px. With the above styling. Inside of the DIV will either be a picture (also 70 by 70) or the text "No Image Available" depending on what the PHP programming finds. So, with the above CSS I get the text inside the div, and looking the way I want it, except for vertical alignment. I need it to be centered.

Reply With Quote
  #4  
Old February 12th, 2004, 10:31 PM
Purple Martin Purple Martin is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Feb 2004
Posts: 30 Purple Martin User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 5
Since you're using PHP to write the contents of the 70x70 div, you could make it write the text inside a paragraph with a big top margin:

<p style="margin-top:30px;">No Image Available</p>

Reply With Quote
  #5  
Old February 12th, 2004, 10:34 PM
Jarrett Green Jarrett Green is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Dec 2003
Posts: 85 Jarrett Green User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 7 h 40 m 11 sec
Reputation Power: 5
Send a message via AIM to Jarrett Green
Yeah i thought about that. But for some reason it wasn't working. i was using a <SPAN> instead of a paragraph. Does the "margin-top" style accept something like "margin-top:50%" ??

Reply With Quote
  #6  
Old February 12th, 2004, 10:37 PM
Purple Martin Purple Martin is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Feb 2004
Posts: 30 Purple Martin User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 5
It should do. Keep experimenting with stuff, I'm sure you're on the right track.

Reply With Quote
  #7  
Old February 12th, 2004, 10:47 PM
brianellisrules brianellisrules is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Feb 2004
Posts: 36 brianellisrules User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 4 h 46 m 38 sec
Reputation Power: 5
try padding-top too.... I think it goes (from the inside of the div, outward) padding > border > margin

Reply With Quote
  #8  
Old February 12th, 2004, 10:50 PM
brianellisrules brianellisrules is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Feb 2004
Posts: 36 brianellisrules User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 4 h 46 m 38 sec
Reputation Power: 5
Quote:
Originally posted by Purple Martin
Since you're using PHP to write the contents of the 70x70 div, you could make it write the text inside a paragraph with a big top margin:

<p style="margin-top:30px;">No Image Available</p>

doesn't this method defeat the purpose of css?

Reply With Quote
  #9  
Old February 12th, 2004, 10:59 PM
Purple Martin Purple Martin is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Feb 2004
Posts: 30 Purple Martin User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 5
what does it defeat, exactly? CSS is only there to change the appearance* of stuff, isn't it?

Maybe you'd prefer to define a class for the paragraph. If there are going to be lots of these 70x70 divs then that's a good idea. If there's only one then an in-line style is appropriate.

*EDIT - Oh yeah, and print, aural etc style. But still same principle.

Reply With Quote
Reply

Viewing: Dev Shed ForumsWeb DesignCSS Help > CSS Vertical Align Question


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 5 hosted by Hostway
Stay green...Green IT