2020年主流PC屏幕分辨率是哪些?原生css响应式设计方法有哪些?

html-css017

2020年主流PC屏幕分辨率是哪些?原生css响应式设计方法有哪些?,第1张

一般情况下,根据分辨率加载pc端 wap端 pad端三个css文件,示例:

<link rel="stylesheet" type="text/css" href="./css/style.css" media="all">

<link rel="stylesheet" href="./css/phone.css" media="(max-width:620px)">

<link rel="stylesheet" href="./css/pad.css" media="screen and (max-width:1024px) and (min-width:621px)">

只有一个css文件情况下,根据分辨率调整css样式,示例:

@media screen and  (max-width:620px){

.logo{width: 300pxmargin-left: -140px}

}

@media screen and  (max-width:1024px) and (min-width:621px) {

.logo{width: 220pxmargin-left: -99px}

.nav li:nth-of-type(2),.nav li:nth-of-type(3){width: 8%}

.nav li:nth-of-type(5),.nav li:nth-of-type(6){width: 12%}

}

您好,使用原生js获取

一、getComputedStyle是一个可以获取当前元素所有最终使用的CSS属性值,

返回的是一个CSS样式声明对象 , 只读, 此方法支持Firefox浏览器

语法:var style=window.getComputedStyle(“元素”,“伪类”)第一个参数是必须的,第二个为可选的。

二、currentStyle 是一款可以兼容IE浏览器的属性返回的是当前所有最终使用的CSS属性值,

利用element.CurrentStyle.attribute可获取

其与getComputedStyle区别:1、 currentStyle不支持伪类样式获取;

2、currentStyle不支持现代浏览器,支持IE

原生JS中如何获取CSS属性中的值