Is there a way to position a div
in the top right corner of a section without overlapping the text of a h1
?
This is the HTML code:
<section>
<h1>some long long long long header, a whole line, 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6</h1>
<div><button>button</button></div>
</section>
I attempted absolute positioning relative to the parent, but the text overlapped, see http://jsfiddle.net/FnpS8/2/
Using this CSS code:
section { position: relative; }
h1 { display: inline; }
div {
position: absolute;
top: 0;
right: 0;
}
I also tried floating the div to the right, but it didn't stay in the top right corner, see http://jsfiddle.net/P6xCw/2/
Using this CSS code:
h1 { display: inline; }
div { float: right; }
I've searched for similar questions but couldn't find a solution specific to this case.