Jquery 使用JavaScript动态创建伪元素CSS
可以动态设置伪元素的CSS吗?例如: jQuery动态设置帮助容器的样式Jquery 使用JavaScript动态创建伪元素CSS,jquery,html,css,pseudo-element,Jquery,Html,Css,Pseudo Element,可以动态设置伪元素的CSS吗?例如: jQuery动态设置帮助容器的样式 $('#help').css({ "width" : windowWidth - xOffset, "height" : windowHeight - yOffset, "bottom" : -windowHeight, "left" : 200 }); jQuery尝试设置帮助容器的内边框: $('#help:before').css({ "width" : windowWidt
$('#help').css({
"width" : windowWidth - xOffset,
"height" : windowHeight - yOffset,
"bottom" : -windowHeight,
"left" : 200
});
jQuery尝试设置帮助容器的内边框:
$('#help:before').css({
"width" : windowWidth - xOffset,
"height" : windowHeight - yOffset
});
上述内容的CSS文件
#help
{
opacity: 0.9;
filter:alpha(opacity=90);
-moz-opacity: 0.9;
z-index: 1000000;
bottom: -550px;
left: 400px;
background-color: #808080;
border: 5px dashed #494949;
-webkit-border-radius: 20px 20px 20px 20px;
-moz-border-radius: 20px 20px 20px 20px;
border-radius: 20px 20px 20px 20px;
}
#help:before
{
border: 5px solid white;
content: '';
position: absolute;
-webkit-border-radius: 20px 20px 20px 20px;
-moz-border-radius: 20px 20px 20px 20px;
border-radius: 20px 20px 20px 20px;
}
与其使用
.css()
设置宽度和高度,不如直接使用.width()
和height()
。不能通过jQuery直接进行设置
看看这个问题:
可能是您实际应该使用的:
因为我确实认为有
是在JS中操作样式表的有效用例
你能为这个发布代码吗,我的代码不起作用:$('#帮助:before').width(windowHeight-410).height(windowHeight-210);可能重复的