目前,我正在尝试使用c#代码将背景图像设置为div,但是当我尝试将背景图像放入div并使用div id将样式设置为:before时,失败了。
下面是我的代码:
CSS代码:
#theme1:before {
   width: 106px;
   content: " ";
   position: absolute;
   left: -16px;
   top: -6px;
   height: 100px;
}ASPX代码:
<div id="theme1" runat="server">
     <div id="theme2" runat="server">
         hello <br/>
     </div>
</div>C#代码:
protected void Page_Load(object sender, EventArgs e)
{
    theme1.Style["background-image"] = "Pic/img.jpg";
    theme2.Style["background-image"] = "Pic/img1.png";
}任何帮助都将不胜感激。谢谢!
发布于 2017-11-19 01:16:13
尝试使用attributes.add而不是style,例如。
Theme1.attributes.add(‘样式’,‘背景图像(图像路径)’)
这应该是可行的
https://stackoverflow.com/questions/47367178
复制相似问题