Remove padding for an empty element

前端 未结 8 501
灰色年华
灰色年华 2021-02-02 05:32

I\'m generating a page for an upcoming portal site, and I\'ve got an HTML element with some optional content. I\'d like the element to not render if it is empty, but adding some

8条回答
  •  悲哀的现实
    2021-02-02 06:24

    You can do the trick with the CSS3 pseudo-class :empty

    .someElement
    {
        // your standard style
    }
    .someElement:empty
    {
        display:none;
    }
    

    Sadly Internet explorer doesn't support that feauture yet. For all the other browsers it shall do just fine...

提交回复
热议问题