HTML,CSS实现鼠标划过头像,头像突出变大(附源码)

话不多说,先上代码

先看原图:

再看 鼠标放上去后的图:

是不是明显感觉到 人物头像突出了一些,而且还增加了阴影部分的效果呢?

直接上代码!!!

html 复制代码
<!--由于我的 img 标签放的是循环后的图片,你可以按照你的数据自行修改  -->
<div class="swiper-slide newly-slide newly-hover speakerList--q4JTz">
	<a class="baseLink--8q29k" target="_blank" href="要跳转的路径">
		<div class="speaker--r2ijq">
      		<div class="speakerPicBox--QeEr9">
           		<div>
           			<img src="图片路径" class="teacher-img" />
        		</div>
           </div> 
       </div>
	</a>
</div>

<!--CSS  可能会有多出来的css,可以忽略掉,多出来的css 是图片右侧的文字的样式...-->
<style>
.speaker--r2ijq{
   box-sizing: border-box;
   cursor: pointer;
   display: flex;
   padding: 8px 12px;
   width: 397px;
}
.speakerProfile--oCOCh{
 flex: 1 1;
 margin-left: 12px;
 overflow: hidden;
}
.speakerName--bKQtn{
 font-size: 22px;
 font-weight: 600;
 line-height: 22px;
 margin-bottom: 8px;
 overflow: hidden;
 text-overflow: ellipsis;
 white-space: nowrap;
 word-break: break-all;
 text-align: left;
 cursor: pointer;
 color: #535353;
 line-height: 33px;
 font-family: SourceHanSansCN-Bold, SourceHanSansCN;
 font-weight: bold;
}
.speakerDesc--vo1ea{
 -webkit-box-orient: vertical;
 -webkit-line-clamp: 2;
 color: #606060;
 display: -webkit-box;
 font-weight: 400;
 line-height: 22px;
 overflow: hidden;
 word-break: break-all;
 text-align: left;
 margin-top: 20px;
 width: 225px;
 height: 44px;
 max-width:225px;
 font-size: 12px;
 font-family: PingFangSC-Regular, PingFang SC;
 cursor: pointer;
}

.speakerList--q4JTz .speaker--r2ijq:hover .speakerPicBox--QeEr9:before{
   background-color: rgba(50,51,53,.1);
   bottom: 0;
   content: "";
   left: 0;
   margin: auto;
   position: absolute;
   right: 228px;
   top: 0;
   z-index: 1;
   width: 144px;
   height: 148px;
   border-radius: 12px;
}
.speakerList--q4JTz .speakerPicBox--QeEr9{
   border-radius: 12px;
   flex-basis: 144px;
   height: 148px;
   overflow: hidden;
}
.speaker--r2ijq:hover .teacher-img {
 transform: scale(1.1);
}
.speaker--r2ijq:hover .speakerName--bKQtn{
 color: #EA7336;
}
.teacher-more{
 display: inline-block;
 padding-top: 60px;
 float: right;
}
.teacher-more>a{
 color: #A3A3A3 !important;
}
.teacher-more>a:hover{
 color: #ff7020!important;
}
</style>

大功告成,如上代码,就是鼠标滑过后,头像或图片突出的代码,快去试试吧!

相关推荐
夏幻灵2 小时前
HTML5里最常用的十大标签
前端·html·html5
程序员猫哥_2 小时前
HTML 生成网页工具推荐:从手写代码到 AI 自动生成网页的进化路径
前端·人工智能·html
杨超越luckly3 小时前
HTML应用指南:利用GET请求获取中国500强企业名单,揭秘企业增长、分化与转型的新常态
前端·数据库·html·可视化·中国500强
夏幻灵5 小时前
CSS三大特性:层叠、继承与优先级解析
前端·css
会编程的土豆21 小时前
新手前端小细节
前端·css·html·项目
周航宇JoeZhou1 天前
JB2-7-HTML
java·前端·容器·html·h5·标签·表单
代码小库1 天前
【课程作业必备】Web开发技术HTML静态网站模板 - 校园动漫社团主题完整源码
前端·html
云计算DevOps-韩老师1 天前
HTML 中的行级元素(inline)、块级元素(block)、行内块元素(inline-block)
html
珹洺1 天前
Bootstrap-HTML(二)深入探索容器,网格系统和排版
前端·css·bootstrap·html·dubbo
BillKu1 天前
VS Code HTML CSS Support 插件详解
前端·css·html