【css】flex展示一排图片

<div class="pics">
			<h1>Album:   </h1>
			<section>
				<h1>pic1</h1>
			</section>
			<section>
				<h1>pic2</h1>
			</section>
			<section>
				<h1>pic3</h1>
			</section>
			<section>
				<h1>pic4</h1>
			</section>
			<section>
				<h1>pic5</h1>
			</section>
		</div>

.pics{
	font: 1.4rem helvetica, sans-serif;
		
	margin: 3rem;
	height: 100%;
	
	/*background: dimgrey;*/
	display: flex;
	align-items: center;
	justify-content: center;
}

section{
	height: 280px;
	margin: 0;
	display: flex;
	flex-flow: column;
	justify-content: flex-end;
	flex: 1;
						
	color: silver;
	background-color: hsla(0, 100%, 0%, .9);
	background-size:  auto 100%; 
	box-shadow: 0 0 1.5rem hsla(0, 100%, 0%, .4);
}

section h1 {
	display: none;
	font-size: 1.3rem;
	font-weight: normal;
	text-align: center;
	text-transform: uppercase;
	text-shadow: 0 0 1.2rem hsla(0, 100%, 0%, .8);
	color: white;
	background-color: hsla(0, 100%, 0%, .7);
	margin: 0;
	padding: .8rem;
}

section:nth-of-type(1) {
	background: white url(image/pic1.jpg) no-repeat center ;
	background-size:  auto 100%; 
}
section:nth-of-type(2) {
	background: white url(image/pic2.jpg) no-repeat center;
	background-size:  auto 100%; 	
}	
section:nth-of-type(3) {
	background: white url(image/pic3.jpg) no-repeat center left;	
	background-size:  auto 100%; 
}
section:nth-of-type(4) {
	background: white url(image/pic4.jpg) no-repeat center;
	background-size:  auto 100%; 
}

section:nth-of-type(5) {
	background: white url(image/pic5.jpg) no-repeat center;
	background-size:  auto 100%; 
}
 section:hover h1 {
	display: block;
}

section:hover{
  flex: 2;
  cursor: pointer;
}


传送门:http://www.w3cplus.com/css3/designing-css-layout-with-flexbox.html


p:nth-of-type(……)    表示“选取父元素的为p子元素的第……个”

p:nth-child(……)   表示“选取父元素的第几个子元素,恰为p”

括号里参数:

1   Odd 和 even 是可用于匹配下标是奇数或偶数的子元素的关键词(第一个子元素的下标是 1)。

p:nth-child(odd)

2   使用公式 (an + b)。描述:表示周期的长度,n 是计数器(从 0 开始),b 是偏移值。

p:nth-child(3n+0)




  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值