html中hover和no-repeat

hover:当鼠标滑上时。

(其实就是给你鼠标要滑上的区域一个超链接,然后给它一个伪类来实现你想要实现的效果。)

(这里以我自己的项目效果为例)

no-repeat:调像素,后边紧跟的是调动的x轴y轴的值。

1.最基本的 当鼠标滑上文字文字变色。

a:hover{

color:red;

}

像这种给文字一个超链接,然后再写一个伪类实现你想要实现的效果。

1.当鼠标滑上时出现红色边框。

.body_body .body_body_img:hover{    
 
    outline: 3px solid red;
}

2.当鼠标划上出现阴影边框。

.body_body .body_body_img:hover{    
    box-shadow: #808080 5px 5px 5px 5px; /*当鼠标划上出现阴影边框*/

}

3.当鼠标划上出现红色下边框。

(1).body_body_img{
    color: gray;
    width: 240px;
    height: 340px;
    background-color: white;
    display: inline-block;
    margin-left: 10px;
    margin-top: 10px;
}
.body_body_img:hover{
    margin-bottom: -7px;
    border-bottom: 3px solid #FF2C72;
}

(2).body_body_img{
    color: gray;
    width: 240px;
    height: 340px;
    background-color: white;
    display: inline-block;
    margin-left: 10px;
    margin-top: 10px;

 border-bottom: 3px solid gainsboro;
}
.body_body_img:hover{
  
    border-bottom: 3px solid #FF2C72;
}

4.当鼠标划上空心的心出现实心的心。

原始给出的材料图是这样的:

可以用下边这段代码调出空心的心:

 width: 15px;
    height: 14px;
    background:url(../img/icon/ico.png) no-repeat 3px -70px ;

 

结合hover要实现功能代码如下:

.list_love{
    width: 15px;
    height: 14px;
    background:url(../img/icon/ico.png) no-repeat 3px -70px ;/*空心的心*/
    margin-left: 30px;
    margin-top: -35px;
}
.list_love:hover{
    background:url(../img/icon/ico.png) no-repeat -12px -70px ;/*实心的心*/
}

 

 

 

 

 

 

 

 

 

<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>学习天地</title> {% load static %} <!-- 加载静态文件标签 --> <style> /* 设置背景图片 */ body { min-height: 10vh; /* 设置最小高度为视口高度 */ margin: 0; /* 移除默认边距 */ padding: 0; /* 移除默认内边距 */ font-family: Arial, sans-serif; background-image: url("{% static 'images/学习天地.jpg' %}"); <!-- 使用静态文件标签加载图片 --> background-size: cover; /* 宽度 300px,高度自动调整 */ background-position: center; <!-- 图片居中显示 --> background-attachment: fixed; background-repeat: no-repeat; <!-- 防止图片重复 --> color: white; <!-- 设置文字颜色为白色,确保在背景上清晰可见 --> } /* 其他样式保持不变 */ .course-list { list-style-type: none; padding: 0; } .course-item { background-color: rgba(249, 249, 249, 0.8); <!-- 添加透明度,使背景图片可见 --> margin: 10px 0; padding: 15px; border-radius: 5px; box-shadow: 0 0 10px rgba(0, 0, 0, 0.1); } .course-item a { color: #007BFF; text-decoration: none; } .course-item a:hover { text-decoration: underline; } .pagination { margin-top: 20px; text-align: center; } .pagination a { margin: 0 5px; color: #007BFF; text-decoration: none; } .pagination a:hover { text-decoration: underline; } </style> </head> <body> <h1 style="font-size: 100px; color:rgb(14, 84, 204);">学习天地</h1> <a href="{% url 'home' %}" style="font-size: 50px; color:rgb(183, 118, 5);">点击进入主页</a> </body> </html>代码运行后,浏览器只能显示背景图片的一部分
03-19
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值