html - How to make text wrapable around following, floated element? -
html:
<div class="heading"> <h2 class="text">lorem ipsum dolor sit amet, consectetur adipiscing elit.</h2> <a class="action" href="#">print</a> </div> desired default look:
| lorem ipsum dolor sit [print] | | amet, consectetur adipiscing elit. | desired on small screen (using media-queries):
| lorem ipsum dolor sit | | amet, consectetur | | adipiscing elit. | | [print] | not desired:
| [print] | | lorem ipsum dolor sit amet, | | consectetur adipiscing elit. | not desired:
| lorem ipsum dolor sit [print] | | amet, consectetur | | adipiscing elit. | remarks:
- text may long.
- action element constant height , variable width.
i see no way using css.
right use js (harvey lib) put floated dom element before text on bigger screen.
any ideas?
/// edit - moved answer (sorry mess)
there's no easy way achieve both results using css without modifying markup. there few tricks can use try emulate behavior want, though.
trick 1: use absolute positioning
set link position:absolute;top:0;right:0; (and container position:relative; if needed). then, use .text::before{display":block;content' ';float:right;} place gap print link appear.
trick 2: double links
you place link before/in <h2> float right large displays, hide , show (formerly-hidden) second link block element below text on small displays.
Comments
Post a Comment