[英]how to change attributes of a class of an elemnet in C#
I have this class 我有这门课
.progress {
width:200px;
height:50px;
border:1px solid black;
position:relative;
}
.progress:after {
position:absolute;
background:black;
top:0; bottom:0;
left:0;
width:10%;
-webkit-animation: filler 2s ease-in-out;
-moz-animation: filler 2s ease-in-out;
animation: filler 2s ease-in-out;
}
and have this div 有这个div
<div id="percentDIV" class="progress" runat="server">some text</div>
I want to change width attribute of progress:after class in c# dynamically. 我想改变进度的宽度属性:c#中的类后动态。 Is it possible? 可能吗?
something like? 就像是?
percentDIV.Attributes["class:progress:after"] = "width:25%";
Declare your next div to runat="server"
and change its style 将你的下一个div声明为runat="server"
并更改其样式
percentDiv.Attributes["style"] = "width:20%";
Styles has precedence over classes. 样式优先于类。
Another way is to remove your class declaration from the CSS and dynamically create it on your page header section with a runat="server"
control, replacing its content with your css class created dynamically. 另一种方法是从CSS中删除类声明,并使用runat="server"
控件在页眉部分动态创建它,用动态创建的css类替换其内容。
percentDIV.Attributes["style"] = "width:20%";
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.