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转换功能transform主要属性值分析及实现分享
May 06 HTML / CSS
CSS3实现伪类hover离开时平滑过渡效果示例
Aug 10 HTML / CSS
html5新增的定时器requestAnimationFrame实现进度条功能
Dec 13 HTML / CSS
html5中localStorage本地存储的简单使用
Jun 16 HTML / CSS
canvas实现图片马赛克的示例代码
Mar 26 HTML / CSS
html5桌面通知(Web Notifications)实例解析
Jul 07 HTML / CSS
h5调用摄像头的实现方法
Jun 01 HTML / CSS
html5 冒号分隔符对齐的实现
Jul 31 HTML / CSS
解析浏览器的一些“滚动”行为鉴赏
Sep 16 HTML / CSS
canvas实现烟花的示例代码
Jan 16 HTML / CSS
在CSS中映射鼠标位置并实现通过鼠标移动控制页面元素效果(实例代码)
Apr 22 HTML / CSS
如何在CSS中绘制曲线图形及展示动画
May 24 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部分常见问题总结
2006/10/09 PHP
PHP 第一节 php简介
2012/04/28 PHP
深入解析PHP垃圾回收机制对内存泄露的处理
2013/06/14 PHP
php socket客户端及服务器端应用实例
2014/07/04 PHP
php将文本文件转换csv输出的方法
2014/12/31 PHP
CodeIgniter自定义控制器MY_Controller用法分析
2016/01/20 PHP
PHP实现适用于自定义的验证码类
2016/06/15 PHP
JavaScript 函数式编程的原理
2009/10/16 Javascript
Extjs单独定义各组件的实例代码
2013/06/25 Javascript
jQuery.parseJSON(json)将JSON字符串转换成js对象
2014/07/27 Javascript
jquery中change()用法实例分析
2015/02/06 Javascript
使用纯javascript实现放大镜效果
2015/03/18 Javascript
jQuery检测返回值的数据类型
2015/07/13 Javascript
详解jQuery移动页面开发中的ui-grid网格布局使用
2015/12/03 Javascript
jQuery的Read()方法代替原生JS详解
2016/11/08 Javascript
nodejs根据ip数组在百度地图中进行定位
2017/03/06 NodeJs
js实现悬浮窗效果(支持拖动)
2017/03/09 Javascript
关于javascript获取内联样式与嵌入式样式的实例
2017/06/01 Javascript
JS实现留言板功能
2017/06/17 Javascript
vue中本地静态图片路径写法
2018/03/06 Javascript
vue-router 起步步骤详解
2019/03/26 Javascript
Vue 打包体积优化方案小结
2020/05/20 Javascript
python实现ip查询示例
2014/03/26 Python
pycharm 使用心得(三)Hello world!
2014/06/05 Python
python调用Delphi写的Dll代码示例
2017/12/05 Python
pytorch 共享参数的示例
2019/08/17 Python
python range实例用法分享
2020/02/06 Python
pandas 强制类型转换 df.astype实例
2020/04/09 Python
Python实现自动装机功能案例分析
2020/10/22 Python
大学生就业自荐信
2013/10/26 职场文书
电脑教师的教学自我评价
2013/11/26 职场文书
护理专科毕业生自荐书范文
2014/02/19 职场文书
入党思想汇报怎么写
2014/04/03 职场文书
企业环保标语
2014/06/10 职场文书
2015年基层党支部工作总结
2015/05/21 职场文书
Golang 获取文件md5校验的方法以及效率对比
2021/05/08 Golang