响应式布局-媒体查询


一、响应式页面是什么?

为适应不同分辨率屏幕,从而开发的能自动改变网页内容的大小、布局的页面

二、实现响应式页面

1.媒体查询@media 格式

代码如下(示例):

<style>
@media (min-width:Xpx) and (max-width:Xpx){  
    			/* CSS样式代码 */ 
	 }
</style>

2.案例

代码如下(示例):

<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8" />
		<title></title>
		<style>
			#card{
				width: 800px;
				height: 400px;
				margin: 20px;
				float: left;
				background-color: black;
			}
			#text{
				margin: 0;
				font-size: 60px;
				text-align: center;
				line-height:400px;
			}
			#text::after{
				content:"";
				display: block;
				clear: both;
			}
			@media (max-width:1440px) and  (min-width:1280px){
				#card{
					width: 700px;
					height: 350px;
					margin: 15px;
					background-color: green;
				}
				#text{
					margin: 0;
					font-size: 50px;
					text-align: center;
					line-height:350px;
				}
			}
			@media (max-width:1280px) and  (min-width:1024px){
				#card{
					width: 600px;
					height: 300px;
					margin: 15px;
					background-color: blue;
				}
				#text{
					margin: 0;
					font-size: 40px;
					text-align: center;
					line-height:350px;
				}
			}
			@media (max-width:1024px) and  (min-width:768px){
				#card{
					width: 500px;
					height: 250px;
					margin: 10px;
					background-color: yellow;
				}
				#text{
					margin: 0;
					font-size: 30px;
					text-align: center;
					line-height:350px;
				}
			}
			@media (max-width:768px) and  (min-width:640px){
				#card{
					width: 400px;
					height: 200px;
					margin: 10px;
					background-color: red;
				}
				#text{
					margin: 0;
					font-size: 25px;
					text-align: center;
					line-height:350px;
				}
			}
			@media (max-width:640px) and  (min-width:375px){
				#card{
					width: 100%;
					height: 200px;
					margin: 10px;
					background-color: pink;
				}
				#text{
					margin: 0;
					font-size: 40px;
					text-align: center;
					line-height:350px;
				}
			}
			@media  (max-width:375px){
				#card{
					width: 100%;
					height: 150px;
					margin: 0px;
					background-color: orange;
				}
				#text{
					margin: 0;
					font-size: 40px;
					text-align: center;
					line-height:350px;
				}
			}
		</style>
	</head>
	<body>
		<div id="card">
			
		</div>
		<div id="text">
			Hello World 
		</div>
		<div id="card">
			
		</div>
		<div id="text">
			Hello World 
		</div>
	</body>
</html>

3.常用分辨率断点

在这里插入图片描述

三、Web开发工具介绍

1.常用编辑器

在这里插入图片描述

2.常用浏览器

在这里插入图片描述


总结

注意:min-width:Xpx 和 max-width:Xpx 的范围关系

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值