Is it possible to set the equivalent of a src attribute of an img tag in CSS?

后端 未结 25 2153
借酒劲吻你
借酒劲吻你 2020-11-22 09:30

Is it possible to set the src attribute value in CSS? At present, what I am doing is:


25条回答
  •  抹茶落季
    2020-11-22 09:58

    They are right. IMG is a content element and CSS is about design. But, how about when you use some content elements or properties for design purposes? I have IMG across my web pages that must change if i change the style (the CSS).

    Well this is a solution for defining IMG presentation (no really the image) in CSS style.

    1. create a 1x1 transparent gif or png.
    2. Assign propery "src" of IMG to that image.
    3. Define final presentation with "background-image" in the CSS style.

    It works like a charm :)

提交回复
热议问题