How to target a specific

前端 未结 6 765
北恋
北恋 2021-02-08 20:27

I\'ve a code of some what like this:

6条回答
  •  日久生厌
    2021-02-08 20:56

    It depends entirely upon which image you want to target. Assuming it's the first (though the implementations are similar for both) image:

    #foo img[src="bar.png"] {
        /* css */
    }
    
    
    #foo img[src^="bar.png"] {
        /* css */
    }
    
    #foo img:first-child {
        /* css */
    }
    
    #foo img:nth-of-type(1) {
        /* css */
    }
    

    References:

    • CSS3 selectors.

提交回复
热议问题