HTML、响应式网页

<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<meta name="viewport" content="width=device-width,initial-scale=1,
			minimum-scale=1,maximum-scale=1,user-scalable=no" />
		<title>响应式网页</title>
		
		<style type="text/css">
			* {box-sizing: border-box;} /* 盒子宽度包含内边距和边框 */
			
			body {
				font-family: "arial, helvetica, sans-serif";
				padding: 10px;
				background-color: #F1F1F1;
			}
			
			/* 页眉  */
			header {
				padding: 30px;
				text-align: center;
				background-color: white;
				border-radius: 10px 10px 0px 0px;
			}
			
			/* 页眉标题  */
			header h1 {font-size: 3em;}
			
			/* 导航栏  */
			nav {
				overflow: hidden;
				background-color: rgba(0, 0, 0, 0.7);
				border-radius: 0px 0px 10px 10px;
			}
			
			/* 导航栏链接  */
			nav a {
				float: left;
				display: block;
				padding: 14px 16px;
				color: white;
				text-align: center;
                transition: .3s;
				text-decoration: none;
			}
			
			/* 导航栏最后一个子元素  */
			nav a:last-child {float: right;}
			
			/* 导航栏链接悬停时  */
			nav a:hover {
				background-color: #ddd;
				color: black;
			}
			
			/* 文章 */
			article {
				float: left;
				width: 75%;
			}
			
			/* 侧边栏  */
			aside {
				float: left;
				width: 25%;
				background-color: #F1F1F1;
				padding-left: 20px;
			}
			
			/* 假图像	*/
			.fakeimg {
				background-color: #aaa;
				width: 100%;
				padding: 20px;
			}
			
			/* 卡片 */
			.card {
				background-color: white;
				padding: 20px;
				margin-top: 20px;
				border-radius: 10px;
			}
			
			/* 清除浮动  */
			.clearfix::after {
				content: "";
				clear: both;
				display: table;
			}
			
			/* 页脚  */
			footer {
				padding: 20px;
				text-align: center;
				margin-top: 20px;
				border-radius: 10px;
				background-color: #DDDDDD;
			}
			
			/* 媒体查询(小于等于800像素) */
			@media only screen and (max-width: 800px) {
				article, aside {
					width: 100%;
					padding: 0;
				}
			}
			
			/* 媒体查询(小于等于600像素)*/
			@media only screen and (max-width: 600px) {
				nav a {
					float: none;
					width: 100%;
				}
			}
		</style>
	</head>
	<body>
		
		<!-- 页眉  -->
		<header>
			<h1>My Website</h1>
			<p>Resize the browser window to see the effect.</p>
		</header>
		
		<!-- 导航栏  -->
		<nav>
			<a href="#">Link</a>
			<a href="#">Link</a>
			<a href="#">Link</a>
			<a href="#">Link</a>
		</nav>
		
		<!-- 节  -->
		<section class="clearfix">
			
			<!-- 章节  -->
			<article>
				<div class="card">
					<h2>TITLE HEADING</h2>
					<h5>Title description, Dec 7, 2017</h5>
					<div class="fakeimg" style="height: 200px;">Image</div>
					<p>Some text..</p>
					<p>Sunt in culpa qui officia deserunt mollit anim id est laborum 
						consectetur adipiscing elit, sed do eiusmod tempor incididunt 
						ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis 
						nostrud exercitation ullamco.</p>
				</div>
				<div class="card">
					<h2>TITLE HEADING</h2>
					<h5>Title description, Dec 7, 2017</h5>
					<div class="fakeimg" style="height: 200px;">Image</div>
					<p>Some text..</p>
					<p>Sunt in culpa qui officia deserunt mollit anim id est laborum 
						consectetur adipiscing elit, sed do eiusmod tempor incididunt 
						ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis 
						nostrud exercitation ullamco.</p>
				</div>
			</article>
			
			<!-- 侧边栏  -->
			<aside>
				<div class="card">
					<h3>About Me</h3>
					<div class="fakeimg" style="height: 100px;">Image</div>
					<p>Some text about me in culpa qui officia deserunt mollit anim..</p>
				</div>
				<div class="card">
					<h3>Popular Post</h3>
					<div class="fakeimg"><p>Image</p></div>
					<div class="fakeimg"><p>Image</p></div>
					<div class="fakeimg"><p>Image</p></div>
				</div>
				<div class="card">
					<h3>Follow Me</h3>
     				<p>Some text..</p>
				</div>
			</aside>
		</section>
		
		<!-- 页脚  -->
		<footer><h2>Footer</h2></footer>
	</body>
</html>

 

 

 

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值