CSS3 实现的缩略图悬停效果


Posted in HTML / CSS onDecember 09, 2020

实现效果

CSS3 实现的缩略图悬停效果

实现代码

html

<header>
		<h1>Thumbnail Hover Effect with <em>CSS3</em></h1>
	</header>
	<div class="wrapper">
		<div class="gallery">
			<ul>
				<li><img src="https://s3-us-west-2.amazonaws.com/s.cdpn.io/53819/9.png"></li>
				<li><img src="https://s3-us-west-2.amazonaws.com/s.cdpn.io/53819/2.png"></li>
				<li><img src="https://s3-us-west-2.amazonaws.com/s.cdpn.io/53819/3.png"></li>
				<li><img src="https://s3-us-west-2.amazonaws.com/s.cdpn.io/53819/1.png"></li>
				<li><img src="https://s3-us-west-2.amazonaws.com/s.cdpn.io/53819/4.png"></li>
				<li><img src="https://s3-us-west-2.amazonaws.com/s.cdpn.io/53819/5.png"></li>
				<li><img src="https://s3-us-west-2.amazonaws.com/s.cdpn.io/53819/7.png"></li>
				<li><img src="https://s3-us-west-2.amazonaws.com/s.cdpn.io/53819/8.png"></li>
				<li><img src="https://s3-us-west-2.amazonaws.com/s.cdpn.io/53819/6.png"></li>
			</ul>
		</div>
		<p class="attribution">Images featured in this demo are the works of <a href="https://d.hatena.ne.jp/koochinko">Mernan Behairi</a>. Inspired by an old post of <a href="https://twitter.com/SohTanaka">@Sohtanaka</a>. It originally uses jQuery. Access original <a href="https://web.archive.org/web/20110323065449/http://www.sohtanaka.com/web-design/fancy-thumbnail-hover-effect-w-jquery/">tutorial</a> and <a href="https://web.archive.org/web/20110323065952/http://www.sohtanaka.com/web-design/examples/image-zoom/">demo</a>.</p>
	</div>

css3

@import url(https://fonts.googleapis.com/css?family=Roboto+Condensed:700);

html, body, div, span, applet, object, iframe,
h1, h2, h3, h4, h5, h6, p, blockquote, pre,
a, abbr, acronym, address, big, cite, code,
del, dfn, em, img, ins, kbd, q, s, samp,
small, strike, strong, sub, sup, tt, var,
b, u, i, center,
dl, dt, dd, ol, ul, li,
fieldset, form, label, legend,
table, caption, tbody, tfoot, thead, tr, th, td,
article, aside, canvas, details, embed, 
figure, figcaption, footer, header, hgroup, 
menu, nav, output, ruby, section, summary,
time, mark, audio, video {
	margin: 0;
	padding: 0;
	border: 0;
	font-size: 100%;
	font: inherit;
	vertical-align: baseline;
}

body {
	background-color: #f2f2f2;
}

header {
	width: 100%;
	background-color: #77cdb4;
	text-align: center;
}

h1 {
	font-family: 'Roboto Condensed', sans-serif;
	color: #FFF;
	font-size: 2.3em;
}

em {
	color: #232027;
}

.wrapper {
	width: 40%;
	margin: 40px auto;
}

div.gallery {
	margin-top: 30px;
}

div.gallery ul {
	list-style-type: none;
	margin-left: 35px;
}

/* animation */
div.gallery ul li, div.gallery li img {
	-webkit-transition: all 0.1s ease-in-out;
  	-moz-transition: all 0.1s ease-in-out;
  	-o-transition: all 0.1s ease-in-out;
  	transition: all 0.1s ease-in-out;
}

div.gallery ul li {
	position: relative;
	float: left;
	width: 130px;
	height: 130px;
	margin: 5px;
	padding: 5px;
	z-index: 0;
}

/* Make sure z-index is higher on hover */
/* Ensure that hover image overlapped the others */
div.gallery ul li:hover {
	z-index: 5;
}

/* Image is position nicely under li */
div.gallery ul li img {
	position: absolute;
	left: 0;
	top: 0;
	border: 1px solid #dddddd;
	padding: 5px;
	width: 130px;
	height: 130px;
	background: #f0f0f0;
}

div.gallery ul li img:hover {
	width: 200px;
	height: 200px;
	margin-top: -130px;
	margin-left: -130px;
	top: 65%;
	left: 65%;
}

p.attribution {
	font-family: 'Consolas';
	color: #000;
	clear: both;
	text-align: center;
	line-height: 25px;
	padding-top: 30px;
}

p.attribution a {
	color: #4c8d7c;
}

/* Responsive hack */
@media only screen and (min-width: 499px) and (max-width: 1212px) {
	.wrapper {
		width: 500px;
	}
}

@media only screen and (max-width: 498px) {
	.wrapper {
		width: 300px;
	}

	div.gallery ul {
		list-style-type: none;
		margin: 0;
	}
}

以上就是CSS3 实现的缩略图悬停效果的详细内容,更多关于CSS3 缩略图悬停的资料请关注三水点靠木其它相关文章!

HTML / CSS 相关文章推荐
今天学到的CSS最新技术(与图片背景相关)
Dec 24 HTML / CSS
css3 transform及原生js实现鼠标拖动3D立方体旋转
Jun 20 HTML / CSS
CSS3动画:5种预载动画效果实例
Apr 05 HTML / CSS
css3通过scale()、rotate()实现放大、旋转
Mar 19 HTML / CSS
html5教程画矩形代码分享
Dec 04 HTML / CSS
html5中的input新属性range使用记录
Sep 05 HTML / CSS
深入理解HTML的FormData对象
May 17 HTML / CSS
浅谈Html5中视频 音频标签 进度条的问题
Jul 26 HTML / CSS
html5本地存储 localStorage操作使用详解
Sep 20 HTML / CSS
html5简介_动力节点Java学院整理
Jul 07 HTML / CSS
通过canvas转换颜色为RGBA格式及性能问题的解决
Nov 22 HTML / CSS
html5 video全屏播放/自动播放的实现示例
Aug 06 HTML / CSS
CSS3 实现的火焰动画
Dec 07 #HTML / CSS
CSS3 实现的加载动画
Dec 07 #HTML / CSS
CSS3实现的渐变幻灯片效果
Dec 07 #HTML / CSS
详解CSS3+JS完美实现放大镜模式
Dec 03 #HTML / CSS
css3中仿放大镜效果的几种方式原理解析
Dec 03 #HTML / CSS
CSS3 实现飘动的云朵动画
Dec 01 #HTML / CSS
CSS3 filter(滤镜)实现网页灰色或者黑色模式的代码
Nov 30 #HTML / CSS
You might like
BBS(php &amp; mysql)完整版(三)
2006/10/09 PHP
PHP开发中四种查询返回结果分析
2011/01/02 PHP
PHP使用数组实现队列
2012/02/05 PHP
PHP分多步骤填写发布信息的简单方法实例代码
2012/09/23 PHP
解析PHP对现有搜索引擎的调用
2013/06/25 PHP
PHP管理依赖(dependency)关系工具 Composer的自动加载(autoload)
2014/08/18 PHP
WordPress过滤垃圾评论的几种主要方法小结
2016/07/11 PHP
Laravel如何使用Redis共享Session
2018/02/23 PHP
PHP实现多图上传和单图上传功能
2018/05/17 PHP
实例分析PHP将字符串转换成数字的方法
2019/01/27 PHP
PHP实现随机发扑克牌
2020/04/22 PHP
Prototype Date对象 学习
2009/07/12 Javascript
文本框的字数限制功能jquery插件
2009/11/24 Javascript
JQuery each()函数如何优化循环DOM结构的性能
2012/12/10 Javascript
使用jQuery实现的网页版的个人简历(可换肤)
2013/04/19 Javascript
jQuery中读取json文件示例代码
2013/05/10 Javascript
JS获取URL中的参数数据
2013/12/05 Javascript
百度判断手机终端并自动跳转js代码及使用实例
2014/06/11 Javascript
浅谈JavaScript中的String对象常用方法
2015/02/25 Javascript
mac上node.js环境的安装测试
2017/07/03 Javascript
微信网页授权并获取用户信息的方法
2018/07/30 Javascript
node.js实现http服务器与浏览器之间的内容缓存操作示例
2020/02/11 Javascript
python执行shell获取硬件参数写入mysql的方法
2014/12/29 Python
Python连接mysql数据库的正确姿势
2016/02/03 Python
python爬虫的工作原理
2017/03/05 Python
Python入门_学会创建并调用函数的方法
2017/05/16 Python
对Python 语音识别框架详解
2018/12/24 Python
python和go语言的区别是什么
2020/07/20 Python
互斥锁解决 Python 中多线程共享全局变量的问题(推荐)
2020/09/28 Python
Css3+Js制作漂亮时钟(附源码)
2013/04/24 HTML / CSS
食品流通安全承诺书
2014/05/22 职场文书
2014年大学生党员评议表自我评价
2014/09/20 职场文书
工地材料员岗位职责
2015/04/11 职场文书
2016年4月份红领巾广播稿
2015/12/21 职场文书
2016年精神文明建设先进个人事迹材料
2016/02/29 职场文书
导游词之唐山景点
2019/12/18 职场文书