![]() | |
![]() |
| | Thread Tools | Display Modes |
#1
| |||
| |||
|
#2
| |||
| |||
|
|
Hi I've created a banner with a drop-shadow using a div - there's a mock- up at http://tinyurl.com/6n7czu . The only problem is that the way I've done it, I have to specify the width of the div - if I don't, it renders with a width of 100%. Is there any way of making the width fit the text it encloses (plus padding), and so that it expand automatically if you add more text? |
#3
| |||
| |||
|
|
Try changing your css to: .BannerWidth1 {width: 11em;} (quick fix) |
#4
| |||
| |||
|
|
Hi dorayme On 8 Apr, 23:01, dorayme <doraymeRidT... (AT) optusnet (DOT) com.au> wrote: Try changing your css to: .BannerWidth1 {width: 11em;} (quick fix) No, I probably didn't explain what I'm trying to achieve very well. I've now updated my mock-up at http://tinyurl.com/6n7czu so that it has a width of 11em, and I've added some more text within the banner (I've added the word "more"); but the width of the banner hasn't increased, and the text has been forced to wrap onto a second line, which I don't want to happen. What I want is for the banner's width to be slightly wider than the width of the widest line of text within it (so no unnecessary wrapping, but also no unnecessary white space), up to a maximum width of 100%, regardless of how much text is within it. Is that possible? |
#5
| |||
| |||
|
|
You have made the text more now and of course it must wrap. |
#6
| |||
| |||
|
|
Hi dorayme On 9 Apr, 01:10, dorayme <doraymeRidT... (AT) optusnet (DOT) com.au> wrote: You have made the text more now and of course it must wrap. But tables do allow one to do what I'm trying to do. |
|
I've now updated my mock-up at http://tinyurl.com/6n7czu again, and if you look at the second banner on the page, which is a table, if you add more text to it, it's width does expand automatically, which is what I'm trying to achieve (so that I don't have to have a hundreds of BannerWidthx styles for all the different banners on my site). |
#7
| |||
| |||
|
|
So why so keen on a table then? |
|
There are a number of things that are shrink-to-fit, and tables cells have this magic property. |
#8
| |||
| |||
|
|
Hi I've created a banner with a drop-shadow using a div - there's a mock- up at http://tinyurl.com/6n7czu . The only problem is that the way I've done it, I have to specify the width of the div - if I don't, it renders with a width of 100%. Is there any way of making the width fit the text it encloses (plus padding), and so that it expand automatically if you add more text? |
#9
| |||
| |||
|
|
You need a shrink-to-fit container, which means a float or display: table, table-cell or inline-block. Most of those don't work in IE and inline-block doesn't in Firefox 2. It looks like you also want the box centered in which case float is out. See http://netweaver.com.au/alt/shrinkTo...ingShrinkToFit.... which has a possible workaround for IE. |
#10
| |||
| |||
|
|
W3C don't think the ability to centre floats is worthwhile |
|
- it makes them seem rather out of touch, to me. |
|
I've got it working using tables, now at http://tinyurl.com/5k8hdy). |
![]() |
| Thread Tools | |
| Display Modes | |
| |