How to reference embedded images from CSS?

后端 未结 4 1660
天涯浪人
天涯浪人 2020-12-08 02:37

I have a CSS file that is embedded in my assembly. I need to set a background image for certain elements using this CSS file, and the image needs to be an embedded resource

4条回答
  •  时光取名叫无心
    2020-12-08 03:10

    <% = WebResource("image1.jpg") %>
    

    You can use above statement inside your CSS file, and while you register your CSS with WebResourceAttribute, you can set "PerformSubstitution" to true

    Default.css
    body{
        background: <%=WebResource("xyz.jpg")%>
    }
    
    
    
    [assembly, WebResource("Default.css","text/css", PerformSubstitution=true)]
    [assembly, WebResource("xyz.jpg","image/jpg")]
    

提交回复
热议问题