![]() | |
![]() |
| | Thread Tools | Display Modes |
#1
| |||
| |||
|
#2
| |||
| |||
|
|
Here's what it should look like: style type="text/css" span.h1 { border-style:solid; border-width:0px; border-color:#000000; border-bottom-width:2px; padding-left:50px; } /style span class="h1">Some Text</span That's exactly what I want - except that I'd rather use a block element (the real h1 for example) instead of the span, because it should behave like a block element (text float etc.). But if I use a block element, it will always cover the whole width of the parent element, and that's not what I want it to do (because this stretches the border-bottom-line over the whole width, too). I could put the span in a div: div><span class="h1">Some Text</span></div But this seems to me like an ugly hack and not like a clean solution. Any hints how I could force a block element to use only the space it needs? Fixed widths are of course not an option as the texts will be of different length. |
#3
| |||
| |||
|
|
Hi! Here's what it should look like: style type="text/css" span.h1 { border-style:solid; border-width:0px; border-color:#000000; border-bottom-width:2px; padding-left:50px; } /style span class="h1">Some Text</span That's exactly what I want - except that I'd rather use a block element (the real h1 for example) instead of the span, because it should behave like a block element (text float etc.). But if I use a block element, it will always cover the whole width of the parent element, and that's not what I want it to do (because this stretches the border-bottom-line over the whole width, too). |
#4
| |||
| |||
|
|
Don't know how badly it goes against the specs, but you could float the h1> left, and set clear:left; on the next element, for instance a <p>. Only works when there are no other blocks to the left of the <p>, or else the clear property will mess things up. |
#5
| |||
| |||
|
|
h1 { padding-left: 50px; text-decoration: underline; } |
#6
| |||
| |||
|
|
Don't know how badly it goes against the specs, but you could float the <h1> left, and set clear:left; on the next element, for instance a p>. Only works when there are no other blocks to the left of the <p>, or else the clear property will mess things up. I thought about that, too, but didn't realize one could do it pretty elegant using h1 { floating:left; } |
|
h1 + * { clear:left; } |
|
If there's no other way to do it, I'll do it like that. Thanks for the tip, |
#7
| |||
| |||
|
|
h1 + * ? |
#8
| |||
| |||
|
|
h1 { floating:left; } make that float:left; or it won't work ;-) |

|
h1 + * { clear:left; } h1 + * ? |
#9
| |||
| |||
|
|
h1 + * { clear:left; } h1 + * ? type1 + type2: Adjacent selectors. See http://www.w3.org/TR/REC-CSS2/select...cent-selectors |
|
*: Universal selector. See http://www.w3.org/TR/REC-CSS2/select...ersal-selector |
|
Or did I miss something? |
#10
| |||
| |||
|
|
On Mon, 07 Jun 2004 22:19:45 +0200, Els <els.aNOSPAM (AT) tiscali (DOT) nl> wrote: h1 + * ? This tells the UA to apply the style to any element follwing an h1. As it won't work in IE, it's rarely used in practice. |
![]() |
| Thread Tools | |
| Display Modes | |
| |