js_week1_1

CSS

@media 媒体查询

当媒体查询被触发时,执行媒体查询内的语块。

常用设备屏幕宽度

PC平板电脑手机
1920 14401280 1024 768812 736 667 568 480…

推荐使用断点

大桌面显示器小桌面显示器横屏平板平板小平板大屏幕手机小屏幕手机
w>14401440-12801280-10241027-768768-640640-375375>w

断点语句

	@media(min-width:px值)
	@media(max-width:px值)

例子:当浏览器窗口长度改变时,改变方块颜色。

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

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值