Is it possible to make any CSS element behave like

前端 未结 4 1096
萌比男神i
萌比男神i 2021-02-06 20:40

I am loading some content inside an iframe. I want this content to behave as-if it was inside a

 tag - namely for it to respect line breaks.  I am using         


        
相关标签:
4条回答
  • 2021-02-06 20:46

    If you're only interested in preserving line breaks but not whitespace then I suggest using:

    body {
        white-space: pre-line;
    }
    

    This will collapse multiple consecutive white space characters into one but preserve line breaks. The downside is that it's only supported in IE versions 8 and up.

    0 讨论(0)
  • 2021-02-06 20:50

    you can find the default setting or how they're suppose to be at http://www.w3.org/TR/CSS2/sample.html just apply the same style to the element you want to behave as a pre element and voila you're done

    p.s. which is basically

    pre{ white-space: pre ; display: block; unicode-bidi: embed }
    
    0 讨论(0)
  • 2021-02-06 21:03

    Try setting the element's white-space style to a value of pre.

    body {
        white-space: pre;
    }
    
    0 讨论(0)
  • 2021-02-06 21:07

    If you just want it to act on linebreaks like pre, use the css: white-space: pre

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