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系列之3D制作方法案例
Aug 14 HTML / CSS
css3 中实现炫酷的loading效果
Apr 26 HTML / CSS
利用CSS3参考手册和CSS3代码生成工具加速来学习网页制
Jul 11 HTML / CSS
CSS3模拟动画下拉菜单效果
Apr 12 HTML / CSS
HTML5中判断横屏竖屏的方法(移动端)
Aug 04 HTML / CSS
html5页面结构_动力节点Java学院整理
Jul 10 HTML / CSS
微信小程序“圣诞帽”的实现思路详解
Dec 28 HTML / CSS
详解html5页面 rem 布局适配方法
Jan 12 HTML / CSS
html5开发三八女王节表白神器
Mar 07 HTML / CSS
html5 http的轮询和Websocket原理
Oct 19 HTML / CSS
详解如何在登录过期后跳出Ifram框架
Sep 10 HTML / CSS
仅仅使用 HTML/CSS 实现各类进度条的方式汇总
Nov 11 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
Discuz 5.0 中读取纯真IP数据库函数分析
2007/03/16 PHP
用PHP实现图象锐化代码
2007/06/14 PHP
php中将汉字转换成拼音的函数代码
2012/09/08 PHP
php笔记之:php数组相关函数的使用
2013/04/26 PHP
PHP数组中头部和尾部添加元素的方法(array_unshift,array_push)
2017/04/10 PHP
利用js实现遮罩以及弹出可移动登录窗口
2013/07/08 Javascript
javascript浏览器兼容教程之事件处理
2014/06/09 Javascript
JQuery zClip插件实现复制页面内容到剪贴板
2015/11/02 Javascript
jquery动态创建div与input的实例代码
2016/10/12 Javascript
jQuery实现文章图片弹出放大效果
2017/04/06 jQuery
React Native 集成jpush-react-native的示例代码
2017/08/16 Javascript
你可能不知道的JSON.stringify()详解
2017/08/17 Javascript
Vue实例中生命周期created和mounted的区别详解
2017/08/25 Javascript
JavaScript惰性求值的一种实现方法示例
2019/01/11 Javascript
原生JS实现的跳一跳小游戏完整实例
2019/01/27 Javascript
在vue中使用echarts(折线图的demo,markline用法)
2020/07/20 Javascript
Python中的yield浅析
2014/06/16 Python
Python 类与元类的深度挖掘 I【经验】
2016/05/06 Python
不要用强制方法杀掉python线程
2017/02/26 Python
Django实战之用户认证(用户登录与注销)
2018/07/16 Python
Python3随机漫步生成数据并绘制
2018/08/27 Python
Python 把序列转换为元组的函数tuple方法
2019/06/27 Python
Django基础知识 URL路由系统详解
2019/07/18 Python
python 错误处理 assert详解
2020/04/20 Python
Python 处理日期时间的Arrow库使用
2020/08/18 Python
对pytorch中x = x.view(x.size(0), -1) 的理解说明
2021/03/03 Python
官方授权图形T恤和服装:Fifth Sun
2019/06/12 全球购物
俄语地区最大的中国商品在线购物网站之一:Umka Mall
2019/11/03 全球购物
劳资专员岗位职责
2013/12/27 职场文书
大二学生学习个人自我评价
2014/01/19 职场文书
财务出纳岗位职责
2014/02/03 职场文书
2014年商场工作总结
2014/11/22 职场文书
2015年度酒店客房部工作总结
2015/05/25 职场文书
中秋联欢会主持词
2015/07/04 职场文书
golang中的空接口使用详解
2021/03/30 Python
MySQL时间盲注的五种延时方法实现
2021/05/18 MySQL