Line break (like
) using only css

前端 未结 3 782
执笔经年
执笔经年 2020-11-27 12:45

Is it possible in pure css, that is without adding additional html tags, to make a line break like
? I want the line break after the

<

相关标签:
3条回答
  • 2020-11-27 13:11

    It works like this:

    h4 {
        display:inline;
    }
    h4:after {
        content:"\a";
        white-space: pre;
    }
    

    Example: http://jsfiddle.net/Bb2d7/

    The trick comes from here: https://stackoverflow.com/a/66000/509752 (to have more explanation)

    0 讨论(0)
  • 2020-11-27 13:12

    You can use ::after to create a 0px-height block after the <h4>, which effectively moves anything after the <h4> to the next line:

    h4 {
      display: inline;
    }
    h4::after {
      content: "";
      display: block;
    }
    <ul>
      <li>
        Text, text, text, text, text. <h4>Sub header</h4>
        Text, text, text, text, text.
      </li>
    </ul>

    0 讨论(0)
  • 2020-11-27 13:32

    Try

    h4{ display:block;}
    

    in your css

    http://jsfiddle.net/ZrJP6/

    0 讨论(0)
提交回复
热议问题