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

后端 未结 4 1651
心在旅途
心在旅途 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:14

    Yeah, sort of — I’d suggest combining padding-left and text-indent:

    HTML





     CSS

    .test {
        width:200px;
    }
    
    .test label {
        display: block;
        padding-left: 1em;
        text-indent: -1em;
    }
    

    text-indent applies only to the first line of text in a block-level element, so it should achieve what you want.

    See http://jsfiddle.net/pauldwaite/qUvvv/

提交回复
热议问题