媒体查询响应式常见的head里写的

<!doctype html>
<html>
<head>
<meta charset="UTF-8">
<title>fayeMeta</title>
<!--适配移动端-->
<meta name="viewport" content="width=device-width,initial-scale=1.0,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no"> 
<!--网页图标-->
<link rel="shortcut icon" type="image/x-icon" href="images/faye .ico" />
<!--重置全局样式-->
<link rel="stylesheet" href="css/reset.css">
<!--字体图标的样式-->
<link rel="stylesheet" href="css/iconfont.css">
<!--公共样式-->
<link rel="stylesheet" href="css/fayeMeta.css">
<!--移动端生效-->
<link rel="stylesheet" href="css/iphone.css" media="screen and (max-width:768px)" >
<!--ipad端生效-->
<link rel="stylesheet" href="css/ipad.css" media="screen and (max-width:992px) and (min-width:768px)">
<!--pc端生效-->
<link rel="stylesheet" href="css/pc.css" media="screen and (min-width:992px)">
</head>

faye是我随便起的,换成你自己的东西名称就可以了哦

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
好的,您可以尝试以下练习: 1. 创建一个响应布局,当屏幕宽度小于等于 768px 时,导航栏变为折叠菜单。 ```html <!DOCTYPE html> <html> <head> <meta charset="UTF-8" /> <title>响应布局练习</title> <style> /* 默认样 */ ul { list-style: none; margin: 0; padding: 0; } li { display: inline-block; } a { display: block; padding: 10px; text-decoration: none; color: #333; } /* 媒体查询 */ @media screen and (max-width: 768px) { /* 折叠菜单 */ ul { display: none; position: absolute; top: 50px; left: 0; width: 100%; background-color: #f9f9f9; z-index: 1; } li { display: block; text-align: center; margin-bottom: 5px; } a { border-bottom: 1px solid #ccc; } /* 显示折叠菜单 */ .menu-toggle:checked ~ ul { display: block; } } </style> </head> <body> <input type="checkbox" id="menu-toggle" /> <label for="menu-toggle">菜单</label> <ul> <li><a href="#">首页</a></li> <li><a href="#">产品</a></li> <li><a href="#">服务</a></li> <li><a href="#">关于我们</a></li> <li><a href="#">联系我们</a></li> </ul> </body> </html> ``` 2. 创建一个响应布局,当屏幕宽度小于等于 480px 时,图片和文字改为垂直排列。 ```html <!DOCTYPE html> <html> <head> <meta charset="UTF-8" /> <title>响应布局练习</title> <style> /* 默认样 */ .container { display: flex; justify-content: center; } .item { margin: 20px; text-align: center; } img { width: 200px; height: 200px; object-fit: cover; border-radius: 50%; } h2 { margin-top: 10px; font-size: 24px; } p { margin-top: 5px; font-size: 16px; color: #999; } /* 媒体查询 */ @media screen and (max-width: 480px) { /* 垂直排列 */ .container { flex-direction: column; } h2 { font-size: 20px; } p { font-size: 14px; } } </style> </head> <body> <div class="container"> <div class="item"> <img src="https://picsum.photos/id/237/200/200" alt="图片" /> <h2>标题</h2> <p>描述</p> </div> <div class="item"> <img src="https://picsum.photos/id/238/200/200" alt="图片" /> <h2>标题</h2> <p>描述</p> </div> <div class="item"> <img src="https://picsum.photos/id/239/200/200" alt="图片" /> <h2>标题</h2> <p>描述</p> </div> </div> </body> </html> ```

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值