Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

CSS Forum


You are currently viewing our CSS Forum as a guest. Please register to participate.
Login



Reply
Class not working for padding, ID works ?
Old 01-02-2008, 04:36 PM Class not working for padding, ID works ?
Skilled Talker

Posts: 78
Trades: 0
I have been a bit confused lately...


<img src="http://www.webmaster-talk.com/images/e-1.jpg height="170" width="250" id="eimage" />

When I use this: #eimage { padding: 20px 30px 20px 30px; } it works.


<img src="http://www.webmaster-talk.com/images/e-1.jpg height="170" width="250" class="eimage" />

But it does not work as a Class, ex: .eimage { padding: 20px 30px 20px 30px; } Only this works as a class: .eimage {padding: 20px;}


Why is this? I would like to use it on multiple image elements, so I cannot use an ID.
Boar is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 01-02-2008, 10:40 PM Re: Class not working for padding, ID works ?
LadynRed's Avatar
Defies a Status

Posts: 10,016
Location: Tennessee
Trades: 0
Looks like a specificity issue. Have to see the rest of the code to know for certain.
__________________
Web Goddess & Web Standards Evangelist :) - Tables Be Gone !!

Please login or register to view this content. Registration is FREE


Please login or register to view this content. Registration is FREE

LadynRed is offline
Reply With Quote
View Public Profile
 
Old 01-04-2008, 05:50 PM Re: Class not working for padding, ID works ?
Skilled Talker

Posts: 78
Trades: 0
Well that is all of the code - so Im not sure.

I am using dreamweaver and safari to view this too - don't know what would happen in IE, but the changes show up in dreamweaver.
Boar is offline
Reply With Quote
View Public Profile
 
Old 01-04-2008, 06:21 PM Re: Class not working for padding, ID works ?
Extreme Talker

Posts: 238
Location: United States
Trades: 0
Other than the missing quote, both examples work for me.
<img src="http://www.webmaster-talk.com/images/e-1.jpg" height="170" width="250" id="eimage" />

Are you sure that you don't have more CSS?
frost is offline
Reply With Quote
View Public Profile
 
Old 01-23-2008, 10:56 AM Re: Class not working for padding, ID works ?
Skilled Talker

Posts: 78
Trades: 0
I would really like to figure this out, ran into this problem again today.

For some reason when I make a class: .text {padding: 20px; } something like that - won't work when I apply it to the text. however if I make it like this #text {padding: 20px; } and apply it with a div, then it works.

Can you not add padding to .classes?
Boar is offline
Reply With Quote
View Public Profile
 
Old 01-23-2008, 11:05 AM Re: Class not working for padding, ID works ?
LadynRed's Avatar
Defies a Status

Posts: 10,016
Location: Tennessee
Trades: 0
Of course you can. The issue is SPECIFICITY. Without seeing ALL your HTML and CSS, there's no way to know what is taking precedence.

Where .text{padding: 20px;} is certainly valid, if that text is inside a div, then your css may have to look like this:

#main .text{padding: 20px;}

http://www.htmldog.com/guides/cssadvanced/specificity/
__________________
Web Goddess & Web Standards Evangelist :) - Tables Be Gone !!

Please login or register to view this content. Registration is FREE


Please login or register to view this content. Registration is FREE

LadynRed is offline
Reply With Quote
View Public Profile
 
Old 01-23-2008, 12:35 PM Re: Class not working for padding, ID works ?
Skilled Talker

Posts: 78
Trades: 0
Well I am not using any div tags so there shouldn't be any issues.

here is a little sample I made, only the left padding works, there should be 100px padding all around - I added a margin and it still doesnt work. I am trying to get top padding.

Code:
<html>
<head>

<style type="text/css">
.text {padding: 100px; margin-top: 100px; font-family: Arial, Helvetica, sans-serif; font-size: 14px; color: #0000FF;}
</style>

</head>

<body>



<table width="294" border="0" cellpadding="0" cellspacing="0">
  <!--DWLayoutTable-->
  <tr>
    <td width="294" height="138" valign="top">
	
	<span class="text">this is a word</span>
	
	</td>
  </tr>
</table>
</body>
</html>

Last edited by Boar; 01-23-2008 at 12:36 PM..
Boar is offline
Reply With Quote
View Public Profile
 
Old 01-23-2008, 03:48 PM Re: Class not working for padding, ID works ?
LadynRed's Avatar
Defies a Status

Posts: 10,016
Location: Tennessee
Trades: 0
Quote:
Well I am not using any div tags
That's your FIRST problem, you shouldn't be using tables for layout.

The problem is THE TABLE !

If you insist on using the table, you're going to have to do it this way:

Quote:
<style type="text/css">

td.text {
padding: 100px;
margin-top: 100px;
font-family: Arial, Helvetica, sans-serif;
font-size: 14px;
color: #0000FF;
background: yellow;
}


</style>
</head>

<body>
<table width="294" border="0" cellpadding="0" cellspacing="0">

<tr>
<td class="text" width="294" >

<p>this is a word</p>

</td>
</tr>
</table>
I put in the yellow background so you could see what's happening.
__________________
Web Goddess & Web Standards Evangelist :) - Tables Be Gone !!

Please login or register to view this content. Registration is FREE


Please login or register to view this content. Registration is FREE

LadynRed is offline
Reply With Quote
View Public Profile
 
Old 01-24-2008, 01:09 AM Re: Class not working for padding, ID works ?
Novice Talker

Posts: 4
Trades: 0
I think you could also apply the padding to your table cell instead of the paragraph
mediarefined is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to Class not working for padding, ID works ?
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.28760 seconds with 12 queries