CSS 鼠标悬停悬浮

<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title>Title</title>
</head>
<style>
  body {
    background-color: #f5f5f5;
    width: 100%;
    height: 100%;
  }
  div {
    text-align: center;
    position: relative;
    display: flex;
    justify-content: center;
    align-items: center;
  }
  .test {
    width: 200px;
    height: 200px;
    background-color: #ffffff;
    float: left;
    list-style: none;
    text-align: center;
    margin: 13px 12px 0 0;
    position: relative;
    transition: all .2s linear;
    top: 0;
  }
  .test:hover {
    top: -5px;
    box-shadow: 5px 5px 5px 5px #e4e4e4;
  }
</style>
<body>
<div>
  <div class="test">
    鼠标悬停悬浮
  </div>
</div>
</body>
</html>

悬停前:
在这里插入图片描述

悬停后:
在这里插入图片描述

在这里插入图片描述

  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
鼠标悬停在图片上时,可以使用CSS的transform属性来实现图片放大效果。通过设置transform: scale(),可以按比例放大或缩小图片。同时,可以使用transition属性来设置动画执行的时间,实现缓慢或快速的执行动画。另外,可以使用:hover伪类选择器来指定鼠标悬停时的样式。例如,可以设置:hover时的transform: scale()值为大于1的数值,使图片放大。同时,可以使用cursor属性将鼠标样式设置为小手,以提醒用户可以点击图片。以下是一个示例代码: ```css .img-wrap { width: 300px; height: 200px; overflow: hidden; } .img-wrap .img { width: 100%; height: 100%; border-top-left-radius: 5px; border-top-right-radius: 5px; transition: all 1s ease 0s; vertical-align: middle; } .img-wrap:hover .img { transform: scale(1.15); } ``` 在上述代码中,.img-wrap类定义了一个容器,设置了宽度和高度,并使用overflow: hidden来隐藏超出容器的部分。.img类定义了图片的样式,包括宽度、高度和边框圆角等。通过设置transition属性,使图片的放大效果具有动画效果。在:hover伪类选择器中,通过设置transform: scale()来实现鼠标悬停时的放大效果。 #### 引用[.reference_title] - *1* [鼠标悬停时图片放大_css3实例](https://blog.csdn.net/chenxiong103/article/details/86061625)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^insertT0,239^v3^insert_chatgpt"}} ] [.reference_item] - *2* [css 实现鼠标悬浮时等比放大图片,鼠标移出时还原图片](https://blog.csdn.net/weixin_43865196/article/details/124420644)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^insertT0,239^v3^insert_chatgpt"}} ] [.reference_item] - *3* [记录 CSS 鼠标悬停图片放大实现](https://blog.csdn.net/weixin_43096828/article/details/122487240)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^insertT0,239^v3^insert_chatgpt"}} ] [.reference_item] [ .reference_list ]
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值