March 5th, 2004, 06:02 AM
CSS DIV width problems
Hope someone can help with this i've set this code below
<td><div class="mystyle">some text here</div></td>
<tr><td>...some other stuff...</td></tr>
The div style sets padding, background colour, font colour and a background image that's aligned to the right hand side;
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??
March 5th, 2004, 06:14 AM
Can't test this, but what about trying this:
<td class="mystyle">some text here</td>
Last edited by jabba_29; March 5th, 2004 at 06:15 AM.
Reason: tidy up :)
>_ My Music Blog | Losing weight @notsoheavyblog | My Tweets
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.
March 5th, 2004, 02:28 PM
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.
<td><span class="mystyle">some text</span></td>
Last edited by kk5st; March 5th, 2004 at 02:31 PM.
Reason: brackle fritzin' typos
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.
My html and css workshop
, demos and tutorials.
Ask a better question
, get a better answer.