<meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no, maximum-scale=1, minimum-scale=1">
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8">
<!-- <meta name="viewport" content="width=375"> -->
<!-- <meta name="viewport" content="width=device-width"> -->
<!-- <meta name="viewport" content="height"> -->
<!-- <meta name="viewport" content="initial-scale=1"> -->
<!-- <meta name="viewport" content="initial-scale=2"> -->
<!-- <meta name="viewport" content="initial-scale=0.5"> -->
<!-- <meta name="viewport" content="width=device-width, initial-scale=1"> -->
<!-- <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no"> -->
<!-- <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, minimum-scale=1"> -->
<meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no, maximum-scale=1, minimum-scale=1">
<title>2.2 视口--viewport</title>
<style>
/*css reset*/
* {
padding: 0;
margin: 0;
}
body {
background-color: #eee;
font-size: 12px;
color: #5d655b;
}
a {
font-size: 12px;
color: #686868;
text-decoration: none;
-webkit-tap-highlight-color: transparent;
}
img {
vertical-align: top;
border: none;
width: 100%;
}
/*recommend*/
.recommend-item {
width: 200px;
background-color: #fff;
box-shadow: 0 1px 1px 0 rgba(0, 0, 0, 0.12);
}
.recommend-link {
display: block;
width: 100%;
height: 100%;
}
.recommend-pic {
width: 100%;
margin-bottom: 8px;
}
.recommend-img {
width: 100%;
height: 100%;
}
.recommend-name,
.recommend-origPrice,
.recommend-info {
padding: 0 10px;
margin-bottom: 8px;
}
.recommend-origPrice {
color: #ccc;
}
.recommend-info {
display: flex;
justify-content: space-between;
align-items: center;
}
.recommend-price {
color: #e61414;
}
.recommend-price-num {
font-size: 20px;
}
.recommend-count {
color: #999;
}
.text-ellipsis {
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
</style>
</head>
<body>
<div class="recommend-item">
<a href="###" class="recommend-link">
<p class="recommend-pic">
<img src="img/2.2-1.jpg" alt="recommend" class="recommend-img">
</p>
<p class="recommend-name text-ellipsis">欧派整体橱柜定制简约现代</p>
<p class="recommend-origPrice">
<del>¥2000.00</del>
</p>
<p class="recommend-info">
<span class="recommend-price">¥<strong class="recommend-price-num">1000</strong></span>
<span class="recommend-count">985件已售</span>
</p>
</a>
</div>
<!-- <img src="img/2.2-2.png" alt="viewport"> -->
<script>
console.log(window.innerWidth);
console.log(document.documentElement.clientWidth);
console.log(document.documentElement.getBoundingClientRect().width);
var viewWidth = document.documentElement.clientWidth || window.innerWidth;
// 兼容性问题,不要用
// console.log(screen.width);
// dpr
console.log(window.devicePixelRatio);
</script>
</body>
</html>