获取设备像素比及屏幕宽高,便于@media机型适配

<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title></title>
	</head>
	<body>
		<script type="text/javascript">
		
		var screenwidth=window.screen.width;
		var screenheight=window.screen.height;
      	document.write(`
		  设备像素比:${
      
      window.devicePixelRatio},
	      屏幕的宽度为:${
      
      screenwidth},
	      屏幕的高度为:${
      
      screenheight}
	    `)
		</script>
	</body>
</html>

猜你喜欢

转载自blog.csdn.net/m0_37285193/article/details/113994060