Hiding an element that contains only spaces using CSS

前端 未结 9 463
不思量自难忘°
不思量自难忘° 2021-01-07 17:34

I am trying to hide the following element in an automatically generated HTML document:

  

相关标签:
9条回答
  • 2021-01-07 18:06

    There's no way to detect empty elements in pure CSS (as yet). If Javascript isn't an option, is there anything you can do server-side to manipulate the HTML before it reaches the browser?

    0 讨论(0)
  • 2021-01-07 18:08

    You could use:

    p.sitspagedesc {
      content: " "; 
      display: none;
    }
    

    Unless you randomly have multiple spaces in there...

    0 讨论(0)
  • 2021-01-07 18:15

    Answer: Not yet, but it's drafted.

    https://drafts.csswg.org/selectors-4/#the-blank-pseudo

    ...and —at least for Mozilla— there's already a prefixed implementation... :-moz-only-whitespace:

    http://jsfiddle.net/peayLrv3/

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