简体   繁体   English

如何通过对象添加z-index?

[英]How to add z-index via object?

Is it possible add z-index via css method thought object: 是否可以通过css方法思想对象添加z-index

jQuery('<div/>').css({
        z-index: 1000, 
        opacity: 0.7, 
        width: jQuery(window).width(), 
        height: jQuery(document).height(), 
        top:0, 
        left:0, 
        position: 'absolute'}).appendTo('body');
$("<div>").css({
    zIndex: 123
}).appendTo("body");

or 要么

$("<div>").css({
    "z-index": 123
}).appendTo("body");

.css() doc : .css()文件

... Also, jQuery can equally interpret the CSS and DOM formatting of multiple-word properties. ...此外,jQuery可以同等地解释多词属性的CSS和DOM格式。 For example, jQuery understands and returns the correct value for both .css({'background-color': ...}) and .css({backgroundColor: ...}) . 例如,jQuery理解并返回.css({'background-color': ...}).css({backgroundColor: ...})的正确值。

jQuery('div').css('z-index',1000);

yes but you have to use apostrophes/quotation 'z-index marks: 是的,但是您必须使用撇号/引号'z-index标记:

jQuery('<div/>').css({
    "z-index": 1000, 
    opacity: 0.7, 
    width: jQuery(window).width(), 
    height: jQuery(document).height(), 
    top:0, 
    left:0, 
    position: 'absolute'}).appendTo('body');

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM