How to line-break from css, without using
?

后端 未结 26 1127
攒了一身酷
攒了一身酷 2020-11-22 15:49

output:

hello
How are you

code:

hello
How are you

Ho

相关标签:
26条回答
  • 2020-11-22 16:28

    In case this helps someone...

    You could do this:

    <p>This is an <a class="on-new-line">inline link</a>?</p>
    

    With this css:

    a.on-new-line:before { 
      content: '&nbsp;'; 
      font-size:0; 
      display:block;
      line-height:0;
    }
    
    0 讨论(0)
  • 2020-11-22 16:29
    <pre> <---------------------------------------
    lorem ipsum
    lorem ipsum
    lorem ipsum
    lorem ipsum
    lorem ipsum
    </pre> <--------------------------------------
    

    OR

    <div style="white-space:pre">  <-----------------------------------
    lorem ipsum
    lorem ipsum
    lorem ipsum
    lorem ipsum
    lorem ipsum
    </div>                         <-----------------------------------
    

    source: https://stackoverflow.com/a/36191199/2377343

    0 讨论(0)
  • 2020-11-22 16:29

    Here's a bad solution to a bad question, but one that literally meets the brief:

    p {
        width : 12ex;
    }
    
    p:before {
        content: ".";
        float: right;
        padding-left: 6ex;
        visibility: hidden;
    }
    
    0 讨论(0)
  • 2020-11-22 16:33

    You need to declare the content within <span class="class_name"></span>. After it the line will be break.

    \A means line feed character.

    .class_name::after {
      content: "\A";
      white-space: pre;
    }
    
    0 讨论(0)
  • 2020-11-22 16:34

    Don't. If you want a hard line break, use one.

    0 讨论(0)
  • 2020-11-22 16:36

    I like very simple solutions, here is the one more

    <p>hello <span>How are you</span></p>
    

    and css

    p {
     display: flex;
     flex-direction: column;
    }
    
    0 讨论(0)
提交回复
热议问题