Welcome, Old Sport!

纯CSS的图像画廊布局

by ilikecss ON 2012/06/06 7282

纯CSS的图像画廊布局

CSS3的Transition属性字面意思是过度,可以理解为从A-B这样,再加以设定其过度时间,怎么样过度(类型)就可以完成一动画效果。题外话了,我在这里利用其属丰富了这个画廊布局,让其更有观赏性,一起来学习如何制作吧,最后提供免费下载Demo。兼容性测试结果: IE6,IE7

Step1. 创建HTML

<div class="label bottomleft"> // bottomleft这个Class是控制鼠标经过的方向,类似有:topright,centerright
  <p>image 01</p>
  <img src="img/lavazza06.jpg" />
</div>

Step2. 创建CSS

/* -----------  LayOut ----------- */
.label {	
	/*Position*/
	overflow: hidden;
	position: relative;
	margin: 20px;
	display: inline-block;
	vertical-align: top;
	/*Skin*/
	border: 7px solid #FAFAFA;
	-webkit-box-shadow: 0px 2px 4px rgba(0,0,0,0.5), 0px 10px 7px rgba(0,0,0,0.2);
	-moz-box-shadow: 0px 2px 4px rgba(0,0,0,0.5), 0px 10px 7px rgba(0,0,0,0.2);
	box-shadow: 0px 2px 4px rgba(0,0,0,0.5), 0px 10px 7px rgba(0,0,0,0.2);
}
.label p {
	/*Position*/
	position: absolute;
	padding: 10px;
	width: 100%;
	/*Skin*/
	background: #000; /*fallback*/
	background: rgba(0,0,0,0.7);
	color: #fff;
	font: bold italic 18px/1.5 Helvtica, Verdana, sans-serif;
	/*Animation*/
	-webkit-transition: all 0.5s ease;
	-moz-transition: all 0.5s ease;
	-o-transition: all 0.5s ease;
	-ms-transition: all 0.5s ease;
	transition: all 0.5s ease;
}
/*Top In Bounds*/
.top:hover p, .topleft p, .topright p {
	top: 0%;
}
/*Top Out of Bounds*/
.top p, .centertop p {
	top: -50%;
}
/*Bottom In Bounds*/
.bottom:hover p, .bottomleft p, .bottomright p {
	bottom: 0%;
}
/*Bottom Out of Bounds*/
.bottom p, .centerbottom p {
	bottom: -50%;
}
/*Left In Bounds*/
.bottomleft:hover p, .bottomright:hover p, .topleft:hover p, .topright:hover p, .centerleft:hover p, .centerright:hover p {
	left: 0%;
}
/*Left Out of Bounds*/
.bottomleft p, .topleft p, .centerleft p, .centerleft p {
	left: -150%;
}
/*Right Out of Bounds 150%*/
.bottomright p, .topright p, .centerright p {
	left: 150%;
}
/*Centered From Bottom*/
.centerbottom:hover p {
	bottom: 50%;
}
/*Centered From Top*/
.centertop:hover p, .centerleft p, .centerright p {
	top: 50%;
}
/*Center Margin Fixes*/
.centertop:hover p, .centerleft p, .centerright p {
	margin-top: -20px;
}
.centerbottom:hover p {
	margin-bottom: -20px;
}
11条评论
  1. 好的文章,支持了,

  2. #2

    金刚禅狮子吼说道:

    好久没见资源下载贴了,支持~ :evil:

  3. #3

    制砂机说道:

    :x 我要把它收藏起来。嘿嘿

  4. 对这个不懂啊




TOP