首页 > 编程知识 正文

下面哪个标签可以HTML页面中引入媒体查询css文件?,媒体查询有几种属性,分别是什么?如何引入?

时间:2023-05-03 19:17:07 阅读:183814 作者:4928

MediaQuery 媒体查询
概念:为不同尺寸的屏幕设定不同的css样式,移动端使用频率高

@#media常用参数

属性名称作用width、height浏览器可视宽度、高度device-width设备屏幕的宽度device-height设备屏幕的高度<head><meta name="viewport" content="width=device-width, initial-scale=1.0"></head>

写法一:style样式表

<style> #div0{width:100px; height:200px } @media screen and (min-device-width:200px) and (max-device-width:300px) {#div0{background-color:red;}} @media screen and (min-device-width:301px) and (max-device-width:500px) {#div0{background-color:blue;}}</style>

写法二:写在style标签中,有条件的执行某个内部样式表

<style media="(min-device-width:200px) and (max-device-width:300px)">#div0{background-color:red;}</style>

写法三: 外部样式表中
写好css样式表,在不同的屏幕中引入对应的样式表

<head><link rel="external nofollow" rel="external nofollow" href="css/css1.css" rel="stylesheet" media="(min-device-width:300px)"><link rel="external nofollow" rel="external nofollow" href="css/css1.css" rel="stylesheet" media="(min-device-width:200px) and (max-device-width:299px)"></head>

版权声明:该文观点仅代表作者本人。处理文章:请发送邮件至 三1五14八八95#扣扣.com 举报,一经查实,本站将立刻删除。