|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
CSS DIV width problems
Hope someone can help with this i've set this code below
<table width="160"> <tr> <td><div class="mystyle">some text here</div></td> </tr> <tr><td>...some other stuff...</td></tr> </table> The div style sets padding, background colour, font colour and a background image that's aligned to the right hand side; .mystyle { font-size: 10px; font-weight: bold; color: #FFFFFF; background: #003366; padding: 6px; white-space: nowrap; } The problem is that the div fills the <td>'s 160px width rather than constraining itself to the with of its content, i've tried adding a minimum width of say 10px which seems to work in IE on PC but nothing else. How can i get it to reliably follow the widths of the content and padding?? |
|
#2
|
||||
|
||||
|
Can't test this, but what about trying this:
Code:
<tr>
<td class="mystyle">some text here</td>
</tr>
__________________
Cheers, Jamie # mdb4u | The mobile movie database | Please help to test and promote # skiFFie | Home of the 'accessibility module' for Drupal # Jamie Burns [me] Accessibility Module [drupal] # guidelines | search | wap resources | not getting help | fold to cure __________________ Let the might of your compassion arise to bring a quick end to the flowing stream of the blood and tears ..... Please hear my anguished words of truth. ![]() __________________ Last edited by jabba_29 : March 5th, 2004 at 06:15 AM. Reason: tidy up :) |
|
#3
|
||||
|
||||
|
div is a block element. By default, it fills the width available in its containing element. IE and Opera will incorrectly "shrink-wrap" certain block elements. In your case, use an inline element rather than block, eg.
Code:
<td><span class="mystyle">some text</span></td> gary
__________________
There are those who manage to build a web site without knowing what they're doing; thereby proving to themselves they do, indeed, know what they're doing. Ask a better question, get a better answer. Last edited by kk5st : March 5th, 2004 at 02:31 PM. Reason: brackle fritzin' typos |
![]() |
| Viewing: Dev Shed Forums > Web Design > CSS Help > CSS DIV width problems |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|