Hide image of specific size, by CSS?

前端 未结 4 1811
梦如初夏
梦如初夏 2021-01-19 23:49

Thanks in advance for your help!

I have an RSS, I want to post the content of this RSS on my page, but the RSS is from WordPress and it contains an image of a button

4条回答
  •  广开言路
    2021-01-20 00:36

    I'd recommend using multiple attribute selectors, in this case add the following code to your CSS stylesheet:

    img[width="72"][height="16"] {
        display: none;
    }
    

    The only problem with this approach is that it wouldn't work in older browsers (e.g. IE 6) because they don't recognize them.

    If you are using the JavaScript library jQuery, you could use the following script:

    $('img').each(function () {
        'use strict';
        var img = $(this);
    
        if (img.width() === 72 && img.height() === 16) {
            img.hide();
        }
    });
    

提交回复
热议问题