开发者

Append text to H1 tag that has wrapped onto 2 lines

开发者 https://www.devze.com 2023-03-31 23:49 出处:网络
I have an H1 tag and on the same line, immediately following the H1 tag I have a link (inside a SPAN). I have both the H1 tag and the SPAN tag set to float:left and they appear on the same line, which

I have an H1 tag and on the same line, immediately following the H1 tag I have a link (inside a SPAN). I have both the H1 tag and the SPAN tag set to float:left and they appear on the same line, which as how I want it.

However, in the occasional sccenario when the H1 tag has so much text it wraps onto a 2nd line, the following SPAN tag (with link inside) no longer sits neatly behind the last part of the H1 tag, but instead appears on the next line down.

<h1 style="float:left;">some really long text here ... blah</h1><span style="float:left;"><a href="">my link</a开发者_StackOverflow中文版></span>

This currently renders like this...

some really long text here ...

blah

my link

..but I'd really like it to appear like this...

some really long text here ...

blah my link

How can I force it to always keep the SPAN (containing my link) directly behind the last word of the H1 tag, WITHOUT resorting to putting my link/span inside the H1 tag block?


Change h1 to display:inline, there's no need for float:left then either.


You can set your H1 to { display:inline; } and remove both floats.


with a width for the h1 or position: absolute for span. but for this you'll need to put h1 and span into a div container


you can define the width of the h1 and the span, it should work.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号