Skip to content

Commit bc717b8

Browse files
committed
较小高度时的界面适配 #18
1 parent 0edf8ab commit bc717b8

File tree

3 files changed

+38
-18
lines changed

3 files changed

+38
-18
lines changed

html/document.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ const ctx = canvas.getContext('2d');
118118

119119
const resize = _=>{
120120
const { offsetWidth, offsetHeight } = htmlEl;
121-
width = Math.min(offsetWidth,800);
121+
width = Math.min(offsetWidth,600);
122122
height = 800;
123123

124124
canvas.width = width;

html/document.less

Lines changed: 36 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -49,22 +49,10 @@ a{
4949
display: block;
5050
height:100%;
5151
}
52-
canvas{
53-
position: absolute;
54-
// box-shadow:0 0 0 2px blue;
55-
// top:0;
56-
left:0;
57-
right:0;
58-
bottom:0;
59-
margin:0 auto;
60-
// width: 100vw;
61-
pointer-events: none;
62-
}
6352
.single-box{
6453
margin:140px auto 0;
65-
width: 200px;
54+
// width: 200px;
6655
height: 500px;
67-
// box-shadow:0 0 0 2px blue;
6856
position: relative;
6957

7058
position: absolute;
@@ -73,6 +61,16 @@ canvas{
7361
right:0;
7462
pointer-events: none;
7563

64+
canvas{
65+
position: absolute;
66+
// top:0;
67+
left:0;
68+
right:0;
69+
bottom:0;
70+
margin:0 auto;
71+
// width: 100vw;
72+
pointer-events: none;
73+
}
7674
.main{
7775
// width: 140px;
7876
// height: 200px;
@@ -84,7 +82,9 @@ canvas{
8482
height: var(--main-height);
8583

8684
position: absolute;
87-
left: calc( 200px / 2 - var(--main-width) / 2 );
85+
left: 0;
86+
right:0;
87+
margin:0 auto;
8888
// top: calc( 240px - var(--main-height) );
8989
bottom: 260px;
9090
// box-shadow:0 0 0 2px red;
@@ -105,7 +105,9 @@ canvas{
105105
width: 160px;
106106
height: 20px;
107107
position: absolute;
108-
left: 20px;
108+
left: 0;
109+
right: 0;
110+
margin: 0 auto;
109111
bottom: 0;
110112
// box-shadow:0 0 0 2px green;
111113
background: rgba(255,255,255,.5) no-repeat 50% 50%;
@@ -198,12 +200,30 @@ html[data-permission-state="true"]{
198200
}
199201

200202

201-
@media (max-height:800px) {
203+
@media (max-height:800px) and (min-height:600px) {
202204
.app{
203205
position: absolute;
204206
top: 0;
205207
left: 0;
206208
right: 0;
207209
min-height: 600px;
208210
}
211+
}
212+
@media (max-height:600px) {
213+
.single-box{
214+
transform: scale(.7);
215+
transform-origin: 50% 100%;
216+
}
217+
}
218+
@media (max-height:450px) {
219+
.single-box{
220+
transform: scale(.6);
221+
transform-origin: 50% 100%;
222+
}
223+
}
224+
@media (max-height:350px) {
225+
.single-box{
226+
transform: scale(.5);
227+
transform-origin: 50% 100%;
228+
}
209229
}

html/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@
1111
</head>
1212
<body>
1313
<div class="app">
14-
<canvas></canvas>
1514
<div class="single-box">
15+
<canvas></canvas>
1616
<div class="main"></div>
1717
<div class="bed"></div>
1818
</div>

0 commit comments

Comments
 (0)