惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

W
WeLiveSecurity
T
The Exploit Database - CXSecurity.com
C
CXSECURITY Database RSS Feed - CXSecurity.com
S
Security @ Cisco Blogs
T
Threat Research - Cisco Blogs
TaoSecurity Blog
TaoSecurity Blog
Recent Commits to openclaw:main
Recent Commits to openclaw:main
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
腾讯CDC
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
T
The Blog of Author Tim Ferriss
Microsoft Azure Blog
Microsoft Azure Blog
罗磊的独立博客
F
Full Disclosure
博客园 - 【当耐特】
C
CERT Recently Published Vulnerability Notes
Engineering at Meta
Engineering at Meta
Application and Cybersecurity Blog
Application and Cybersecurity Blog
T
Threatpost
I
Intezer
V2EX - 技术
V2EX - 技术
H
Hackread – Cybersecurity News, Data Breaches, AI and More
The Hacker News
The Hacker News
小众软件
小众软件
Google DeepMind News
Google DeepMind News
T
Tailwind CSS Blog
D
Darknet – Hacking Tools, Hacker News & Cyber Security
B
Blog RSS Feed
Microsoft Security Blog
Microsoft Security Blog
N
News | PayPal Newsroom
MyScale Blog
MyScale Blog
AI
AI
Vercel News
Vercel News
Spread Privacy
Spread Privacy
美团技术团队
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
The GitHub Blog
The GitHub Blog
V
Vulnerabilities – Threatpost
Schneier on Security
Schneier on Security
Cyberwarzone
Cyberwarzone
G
GRAHAM CLULEY
Help Net Security
Help Net Security
Hacker News: Ask HN
Hacker News: Ask HN
Google DeepMind News
Google DeepMind News
MongoDB | Blog
MongoDB | Blog
L
LINUX DO - 热门话题
U
Unit 42
L
LangChain Blog
Recent Announcements
Recent Announcements

博客园 - NewSea

Linux 安装IntelAx211无线网卡 解决 K8sApi 部署后报 Unknown apiVersionKind apps/v1/Deployment is it registered? Docker 启动前后端脚本 docker 一键启动 mariadb 分区脚本 Spring笔记--@ConditionalOnBean坑 K8s笔记 ubuntu18+k8s单机版+kuboard+harbor安装笔记 yapi 自定义Json的数据类型 Nginx笔记 k3s+rancher+harbor 笔记 postgresql 笔记 vscode 笔记 发布Jar包到中央仓库 Java开发笔记汇总 - NewSea - 博客园 nui-app 笔记 Java里的不能与无用. SSH 配置 Swagger 配置
css 适配
NewSea · 2019-05-23 · via 博客园 - NewSea

https://blog.csdn.net/weixin_35467885/article/details/80778992

1、通过link方法

link方法引入媒体类型其实就是在标签引用样式的时候,通过link标签中的media属性来指定不同的媒体类型。这种方式引入媒体类型时常跟着引用的样式文件走,如下所示。

    <!--手机端-->
    <link rel="stylesheet" type="text/css" href="style_phone.css" media="screen and (max-width: 960px)"/>
    <!--电脑端-->
    <link rel="stylesheet" type="text/css" href="style_PC.css" media="screen and (min-width: 960px)"/>

2、使用@media

@media是CSS3中引进的一个特性,称为媒体查询,可以直接写在中间或者外部样式文件中。例如,查询媒体是否是屏幕,屏幕尺寸是否小于960px:

    @media screen and (max-width: 960px){
      /* 手机端CSS代码 */
    }
     
    @media screen and (min-width: 960px){
      /* 电脑端CSS代码 */
    }

以上就是最经典判断是电脑端还是手机端。