Can you apply CSS only on text that is wrapped, i.e. the second and subsequent lines?

后端 未结 4 1650
心在旅途
心在旅途 2021-01-07 18:07

I want to put a margin-left on only the text that is wrapped, i.e. text after the first line:

This is text with no margin left
     this text ha         


        
4条回答
  •  情话喂你
    2021-01-07 18:17

    No, but you can apply CSS to the first line, so you could reverse your thinking to achieve the same effect.

    Something like this:

    .mytext {margin-left:-5em;}
    .mytext:first-line {margin-left:0;}
    

    Here's a JSFiddle example of it working: http://jsfiddle.net/4ckxJ/3/

    See http://www.quirksmode.org/css/firstline.html for more info on the :first-line pseudo-class.

提交回复
热议问题