Fontawesome icon prevent newline wrapping

前端 未结 4 1085
借酒劲吻你
借酒劲吻你 2021-01-01 10:36

how can I prevent a newline to be inserted between a fontawesome icon and the text that is near this icon ?

See the fiddle, I have a nbsp, but it is discarded.

4条回答
  •  無奈伤痛
    2021-01-01 11:20

    Since the text you're trying to NOT wrap is not inside any element, how would css know where to wrap or not wrap? The width of the jsfiddle .test was 20px, that is the same width (approx) of the icon, so I don't really understand. If you don't want something to wrap, here's one way of doing this, wrap what you want to not wrap inside an inline element, like a span, then add the class you want on that span.

    HTML Abcdef ghijklmnopqrstuvwxyz

    CSS:

    .test {
        width: 100px; /*20px is too small the icon is 20px (approx) you need more space */
    }
    
    .test span {white-space:nowrap}
    

    Demo: http://jsbin.com/rineye/2/edit

提交回复
热议问题