<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
<style>
#one{
width:150px;
height:25px;
border:1px solid red;
}
#two{
width:500px;
height:500px;
}
</style>
</head>
<body>
<div id="one"><input type="button"onmouseover="show1()"value="篮球"><input type="button"onmouseover="show2()"value="足球"><input type="button"onmouseover="show3()"value="乒乓球"></div>
<div id="two">
</div>
<script>
function show1()
{
var two=document.getElementById("two");
two.setAttribute("style","background-image:url(1.jpg)")
}
function show2()
{
var two=document.getElementById("two");
two.setAttribute("style","background-image:url(2.jpg)")
}
function show3()
{
var two=document.getElementById("two");
two.setAttribute("style","background-image:url(3.jpg)")
}
</script>
</html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
<style>
#one{
width:150px;
height:25px;
border:1px solid red;
}
#two{
width:500px;
height:500px;
}
</style>
</head>
<body>
<div id="one"><input type="button"onmouseover="show1()"value="篮球"><input type="button"onmouseover="show2()"value="足球"><input type="button"onmouseover="show3()"value="乒乓球"></div>
<div id="two">
</div>
<script>
function show1()
{
var two=document.getElementById("two");
two.setAttribute("style","background-image:url(1.jpg)")
}
function show2()
{
var two=document.getElementById("two");
two.setAttribute("style","background-image:url(2.jpg)")
}
function show3()
{
var two=document.getElementById("two");
two.setAttribute("style","background-image:url(3.jpg)")
}
</script>
</html>
本文介绍了一个简单的网页设计案例,使用HTML、CSS和JavaScript实现了当鼠标悬停在不同按钮上时背景图片的切换效果。该案例适用于初学者了解基本的网页布局及交互设计。
1031

被折叠的 条评论
为什么被折叠?



