Bootstrap 第23章 首页内容[下]

<!DOCTYPE html>
<html lang="zh-cn">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1,maximum-scale=1, user-scalable=no">
<title></title>
<link href="css/bootstrap.min.css" rel="stylesheet">
<style>
body { font-family: "Helvetica Neue", Helvetica, Arial, "Microsoft Yahei UI", "Microsoft YaHei", SimHei, "\5B8B\4F53", simsun, sans-serif; }
.tab2 {
	background-color: #eee;
	padding: 60px 20px;
	text-align: center;
}
.tab2 img {
	width: 40%;
	height: 40%;
}
.tab3 {
	padding: 60px 20px;
	text-align: center;
}
.tab3 img {
	width: 65%;
	height: 65%;
}
.text h3 {
	font-size: 20px;
}
.text p {
	font-size: 14px;
}
#footer {
	background-color: #eee;
	border-top: 1px solid #ccc;
	padding: 20px;
	text-align: center;
}
/*没有小于768px,是因为Bootstrap3以移动端优先设计*/

/* 小屏幕(平板,大于等于768px) */
@media (min-width: 768px) {
	.text h3 {
		font-size: 22px;
	}
	.text p {
		font-size: 15px;
	}
	.tab2-text {
		float: left;
	}
	.tab2-img {
		float: right;
	}
}

/* 中等屏幕(桌面显示器,大于等于992px) */
@media (min-width: 992px) {
	.text h3 {
		font-size: 24px;
	}
	.text p {
		font-size: 16px;
	}
}

/* 大屏幕(大桌面显示器,大于等于1200px) */
@media (min-width: 1200px) {
	.text h3 {
		font-size: 26px;
	}
	.text p {
		font-size: 18px;
	}
}
</style>
</head>
<body>
<div class="tab2">
	<div class="container">
		<div class="row">
			<div class="col-md-6 col-sm-6 tab2-img">
				<img src="img/tab2.png" class="auto img-responsive center-block" alt="">
			</div>
			<div class="text col-md-6 col-sm-6 tab2-text">
				<h3>阅谁问君诵</h3>
				<p>阅谁问君诵,水落清香浮。阅谁问君诵,水落清香浮。</p>
			</div>
		</div>
	</div>
</div>
<div class="tab3">
	<div class="container">
		<div class="row">
			<div class="col-md-6 col-sm-6">
				<img src="img/tab3.png" class="auto img-responsive center-block" alt="">
			</div>
			<div class="text col-md-6 col-sm-6">
				<h3>阅谁问君诵</h3>
				<p>阅谁问君诵,水落清香浮。阅谁问君诵,水落清香浮。</p>
			</div>
		</div>
	</div>
</div>
<div style="height: 10000px;"></div>
<script src="js/jquery.min.js"></script>
<script src="js/bootstrap.min.js"></script>
<script>
$(function () {
	//设置文字垂直居中
	$('.text').eq(0).css('margin-top', ($('.auto').eq(0).height() - $('.text').eq(0).height()) / 2 + 'px');
	$(window).resize(function () {
		$('.text').eq(0).css('margin-top', ($('.auto').eq(0).height() - $('.text').eq(0).height()) / 2 + 'px');
	});
	$('.text').eq(1).css('margin-top', ($('.auto').eq(1).height() - $('.text').eq(1).height()) / 2 + 'px');
	$(window).resize(function () {
		$('.text').eq(1).css('margin-top', ($('.auto').eq(1).height() - $('.text').eq(1).height()) / 2 + 'px');
	});
});
</script>
</body>
</html>

效果图:

 

猜你喜欢

转载自onestopweb.iteye.com/blog/2271557