css - prevent :after element from wrapping to next line -


i have html:

<ul>     <li class="completed"><a href="#">i want icon stay on same line last <strong>word</strong></li> </ul> 

i'm appending icon using :after pseudo element:

ul li.completed a:after {     background:transparent url(img.png) no-repeat;      content: '';     display:inline-block;     width: 24px;     height: 16px; } 

the problem: if available width small, icon wraps next line. want stay on same line last word of link it's appended to:

enter image description here

is doable, without adding 'nowrap' entire link (i want words wrap, not icon).

see jsfiddle here.

you can add image last word instead. make break together.

add class word <strong class="test">word</strong>

and .test:after { ...

http://jsfiddle.net/52dkr/

the trick make class inline-block

and if want keep underline see this.

http://jsfiddle.net/atcjj/

add text-decoration:inherit;


Comments

Popular posts from this blog

node.js - Bad Request - node js ajax post -

Why does Ruby on Rails generate add a blank line to the end of a file? -

keyboard - Smiles and long press feature in Android -