gpt4 book ai didi

html - 鼠标悬停时如何更改整个网站背景颜色

转载 作者:行者123 更新时间:2023-11-28 16:08:13 30 4
gpt4 key购买 nike

当我将鼠标悬停在图像、文本等上时,如何更改整个网站的背景颜色

最佳答案

希望这对您有所帮助。但您可能需要一点 jquery。粘贴并尝试。您可能需要互联网连接,因为我已经在线链接了 jquery。

<html xmlns="http://www.w3.org/1999/xhtml">
<head>

<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>jquery</title>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.0/jquery.min.js"></script>
<style type="text/css">
.classOne{
background-color: orange;
color: white;
}

.changeme{
cursor:pointer;
}

</style>

</head>

<body>
<p class="changeme">change the body background color</p>


<script type="text/javascript">
$(document).ready(function(){
$(".changeme").mouseenter(function(){
$('body').addClass("classOne");
});
$(".changeme").mouseleave(function(){
$('body').removeClass("classOne");
});


});
</script>


</body>
</html>

您可以将它与任何其他元素一起使用,例如任何 img、div 等....

或者,如果你只想用css改变body背景,你可以像这样使用hover

<html xmlns="http://www.w3.org/1999/xhtml">
<head>

<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>jquery</title>

<style type="text/css">

body:hover{
background-color: orange;
color: white;
}

</style>

</head>

<body>
<p>change the body background color</p>


</body>
</html>

关于html - 鼠标悬停时如何更改整个网站背景颜色,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35256994/

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