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 相关文章推荐
CSS3样式linear-gradient的使用实例
Jan 16 HTML / CSS
HTML5 CSS3给网站设计带来出色效果
Jul 16 HTML / CSS
利用CSS3参考手册和CSS3代码生成工具加速来学习网页制
Jul 11 HTML / CSS
css3 实现滚动条美化效果的实例代码
Jan 06 HTML / CSS
html5 乒乓球(碰撞检测)实例二
Jul 25 HTML / CSS
HTML5 window/iframe跨域传递消息 API介绍
Aug 26 HTML / CSS
HTML5 canvas画矩形时出现边框样式不一致的解决方法
Oct 14 HTML / CSS
分享全球十款超强HTML5开发工具
May 14 HTML / CSS
很酷的HTML5电子书翻页动画特效
Feb 25 HTML / CSS
Html5原创俄罗斯方块(基于canvas)
Jan 07 HTML / CSS
在html页面中取得session中的值的方法
Aug 11 HTML / CSS
AmazeUi Tree(树形结构) 应用小结
Aug 17 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
PHP分页显示制作详细讲解
2008/11/19 PHP
apache+codeigniter 通过.htcaccess做动态二级域名解析
2012/07/01 PHP
PHP实现上传文件并存进数据库的方法
2015/07/16 PHP
PHP代码优化技巧小结
2015/09/29 PHP
php编程中echo用逗号和用点号连接的区别
2016/03/26 PHP
php常用字符函数实例小结
2016/12/29 PHP
PHP实现添加购物车功能
2017/03/06 PHP
Laravel框架模板加载,分配变量及简单路由功能示例
2018/06/11 PHP
PHP PDOStatement::bindValue讲解
2019/01/30 PHP
Laravel基础_关于view共享数据的示例讲解
2019/10/14 PHP
使用JQuery和s3captche实现一个水果名字的验证
2009/08/14 Javascript
判断iframe是否加载完成的完美方法
2010/01/07 Javascript
JS delegate与live浅析
2013/12/21 Javascript
nodejs开发微博实例
2015/03/25 NodeJs
Javascript动画效果(3)
2016/10/11 Javascript
JavaScript表单验证完美代码
2017/03/02 Javascript
JavaScript面向对象精要(上部)
2017/09/12 Javascript
基于vue-cli搭建多模块且各模块独立打包的项目
2019/06/12 Javascript
Vue中import from的来源及省略后缀与加载文件夹问题
2020/02/09 Javascript
谈谈JavaScript中的函数
2020/09/08 Javascript
python利用不到一百行代码实现一个小siri
2017/03/02 Python
Python使用回溯法子集树模板解决爬楼梯问题示例
2017/09/08 Python
python numpy数组的索引和切片的操作方法
2018/10/20 Python
树莓派动作捕捉抓拍存储图像脚本
2019/06/22 Python
py-charm延长试用期限实例
2019/12/22 Python
Python实现计算图像RGB均值方式
2020/06/04 Python
Python3.9 beta2版本发布了,看看这7个新的PEP都是什么
2020/06/10 Python
K近邻法(KNN)相关知识总结以及如何用python实现
2021/01/28 Python
CSS3实现伪类hover离开时平滑过渡效果示例
2017/08/10 HTML / CSS
Priority Pass机场贵宾室会籍计划:全球超过1200间机场贵宾室
2018/08/26 全球购物
Senreve官网:美国旧金山的奢侈手袋品牌
2019/03/21 全球购物
日语系毕业生推荐信
2013/11/11 职场文书
公司部门司机岗位职责
2014/01/03 职场文书
高三地理教学反思
2014/01/11 职场文书
自我工作评价范文
2015/03/06 职场文书
python批量创建变量并赋值操作
2021/06/03 Python