Html 如何在页面加载事件中将atribute添加到页面的css中

Html 如何在页面加载事件中将atribute添加到页面的css中,html,css,Html,Css,加载页面后,我想在body:after psuedo元素中添加background:rgba226、93、141、0.76属性 以下是我的html和css: <style runat="server" id="myStyle" > body:after{ position:fixed; content:""; top:0; left:0; right:0; bottom:0; z-index:-1; } </style&

加载页面后,我想在body:after psuedo元素中添加background:rgba226、93、141、0.76属性

以下是我的html和css:

<style runat="server" id="myStyle"  >
body:after{
    position:fixed;
    content:"";
    top:0;
    left:0;
    right:0;
    bottom:0;
    z-index:-1;
}
</style>
如何在页面加载事件中访问body:after元素?

创建一个新类'loaded',并将其添加到body

body:after{
    position:fixed;
    content:"";
    top:0;
    left:0;
    right:0;
    bottom:0;
    z-index:-1;
}

body.loaded:after{
    background:rgba(226, 93, 141, 0.76);
}
&然后根据Faiz Ahmed的建议使用jQuery修订:

$(window).load(function() {
   $('body').addClass('loaded');
});
问题解决了:

     protected void Page_Load(object sender, EventArgs e)
            {
                mystyle.InnerHtml = " body:after{ 
position:fixed;
content:'';
 top:0;
left:0;
right:0;
bottom:0;
z-index:-1;
background:rgba(226, 93, 141, 0.76)";
            }





<style runat="server" id="myStyle"  >

</style>