CSS targeting specific images

后端 未结 2 1500
一生所求
一生所求 2021-01-15 15:09

I am looking for a way to target a specific image with CSS, if this is even possible.

I am running a CMS where the users can upload images and put them on their page

相关标签:
2条回答
  • 2021-01-15 15:51
    img[width="400"]{
       float:left;
    }
    

    This will make any image that have the attribute set to 400 float left:

    <img src="image.jpg" width="400" />
    

    Note: this will only work if the width attribute is set. Will not work if the image is 400px wide but does not have a width attribute set.

    0 讨论(0)
  • 2021-01-15 16:01

    According to the spec this should work

    img[width=400]
    

    but I haven't tried it

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