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教程:CSS3圆角属性
Apr 02 HTML / CSS
css3简单练习实现遨游浏览器logo的绘制
Jan 30 HTML / CSS
CSS3制作Dropdown下拉菜单的方法
Jul 18 HTML / CSS
使用CSS3配合IE滤镜实现渐变和投影的效果
Sep 06 HTML / CSS
CSS3中使用RGBa来调节透明度的教程
May 09 HTML / CSS
利用css3画个同心圆示例代码
Jul 03 HTML / CSS
CSS3实现酷炫的3D旋转透视效果
Nov 21 HTML / CSS
HTML5 实战PHP之Web页面表单设计
Oct 09 HTML / CSS
【HTML5】3D模型--百行代码实现旋转立体魔方实例
Dec 16 HTML / CSS
使用phonegap进行本地存储的实现方法
Mar 31 HTML / CSS
canvas 橡皮筋式线条绘图应用方法
Feb 13 HTML / CSS
如何使用 resize 实现图片切换预览功能
Aug 23 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和ACCESS写聊天室(八)
2006/10/09 PHP
yii2带搜索功能的下拉框实例详解
2016/05/12 PHP
浅谈Yii乐观锁的使用及原理
2017/07/25 PHP
PHP实现的CURL非阻塞调用类
2018/07/26 PHP
PHP 使用位运算实现四则运算的代码
2021/03/09 PHP
用JS实现的一个include函数
2007/07/21 Javascript
javascript中的prototype属性使用说明(函数功能扩展)
2010/08/16 Javascript
使用JS 清空File控件的路径值
2013/07/08 Javascript
javascript实现点击按钮让DIV层弹性移动的方法
2015/02/24 Javascript
再谈javascript注入 黑客必备!
2016/09/14 Javascript
javascript滚轮控制模拟滚动条
2016/10/19 Javascript
JS定时器实现数值从0到10来回变化
2016/12/09 Javascript
微信小程序 JS动态修改样式的实现代码
2017/02/10 Javascript
使用js获取伪元素的content实例
2017/10/24 Javascript
jQuery实现标签子元素的添加和赋值方法
2018/02/24 jQuery
Webpack 4.x搭建react开发环境的方法步骤
2018/08/15 Javascript
值得收藏的八个常用的js正则表达式
2018/10/19 Javascript
详解vue后台系统登录态管理
2019/04/02 Javascript
ES6知识点整理之模块化的应用详解
2019/04/15 Javascript
JS面向对象编程——ES6 中class的继承用法详解
2020/03/03 Javascript
[05:08]顺网杯ISS-DOTA2赛歌 少女偶像Lunar青春演绎
2013/12/05 DOTA
[05:13]2018DOTA2亚洲邀请赛主赛事第二日战况回顾 LGD、VG双雄携手晋级
2018/04/05 DOTA
python算法学习之基数排序实例
2013/12/18 Python
Python读取ini文件、操作mysql、发送邮件实例
2015/01/01 Python
Python Sleep休眠函数使用简单实例
2015/02/02 Python
Python获取某一天是星期几的方法示例
2017/01/17 Python
python绘制多个子图的实例
2019/07/07 Python
Python的几种主动结束程序方式
2019/11/22 Python
Python2及Python3如何实现兼容切换
2020/09/01 Python
浅析canvas元素的html尺寸和css尺寸对元素视觉的影响
2019/07/22 HTML / CSS
英国在线自行车店:Merlin Cycles
2018/08/20 全球购物
Mamaearth官方网站:印度母婴护理产品公司
2019/10/06 全球购物
2015重阳节座谈会主持词
2015/07/30 职场文书
redis连接被拒绝的解决方案
2021/04/12 Redis
Python超简单容易上手的画图工具库推荐
2021/05/10 Python
vue中的可拖拽宽度div的实现示例
2022/04/08 Vue.js