gpt4 book ai didi

jquery - 在 Webkit 浏览器上使用 jQuery 读取和设置 z-index 值

转载 作者:技术小花猫 更新时间:2023-10-29 11:27:51 24 4
gpt4 key购买 nike

jQuery("#X").css("z-index"); 在 Webkit 浏览器上总是返回“auto”。在 Firefox 上运行正常。

您似乎也无法使用类似以下内容设置 z-index:jQuery("#X").css("z-index",5);

测试用例如下:

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>jQuery CSS Z-index Fail</title>
<script src="http://code.jquery.com/jquery-1.6.1.min.js"></script>
<script type="text/javascript">
$(document).ready(function(){
$("#X").css("z-index",5);
$("#Y").append($("#X").css("z-index"));
});
</script>
<style type="text/css">
h1 {z-index: 3;}
</style>
</head>
<body>
<h1 id="X">Some Text</h1>
<div id="Y"> Z-index is: </div>
</body>
</html>

最佳答案

您需要指定位置才能使用 z-index。

<h1 id="X" style='position:relative;'>Some Text</h1>

立即在 Chrome 中修复它。

关于jquery - 在 Webkit 浏览器上使用 jQuery 读取和设置 z-index 值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6476360/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com