一、语法
鼠标样式 cursor
li {cursor: pointer; }
设置或检索在对象上移动的鼠标指针采用何种系统预定义的光标形状。

案例:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>cursor鼠标形状</title>
<style>
.box1{
width: 100px;
height: 100px;
background-color: red;
/* 鼠标形状 小手 */
cursor: pointer;
}
.box2{
width: 100px;
height: 100px;
background-color: green;
/* 鼠标形状 移动 */
cursor: move;
}
.box3{
width: 100px;
height: 100px;
background-color: blue;
/* 鼠标形状 文本 */
cursor: text;
}
.box4{
width: 100px;
height: 100px;
background-color: black;
/* 鼠标形状 禁止 */
cursor: not-allowed;
}
</style>
</head>
<body>
<div class="box1"></div>
<div class="box2"></div>
<div class="box3"></div>
<div class="box4"></div>
</body>
</html>
效果:

本文介绍了CSS中cursor属性的使用,用于设置鼠标在元素上移动时的指针形状。通过示例展示了pointer(小手)、move(移动)、text(文本)和not-allowed(禁止)四种常见光标形状的实现,帮助理解并应用到网页设计中。
340

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



