Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
H
hu-shoujijingfen-h5
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
chenweisong
hu-shoujijingfen-h5
Commits
623321d8
Commit
623321d8
authored
Sep 28, 2020
by
chenweisong
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fixed 字体随机子字体改变导致布局变形的bug
parent
77691b6f
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
56 additions
and
16 deletions
+56
-16
index.html
public/index.html
+56
-16
No files found.
public/index.html
View file @
623321d8
<!DOCTYPE html>
<!DOCTYPE html>
<html
lang=
"en"
>
<html
lang=
"en"
>
<head>
<head>
<meta
charset=
"utf-8"
>
<meta
charset=
"utf-8"
>
<meta
http-equiv=
"X-UA-Compatible"
content=
"IE=edge"
>
<meta
http-equiv=
"X-UA-Compatible"
content=
"IE=edge"
>
<meta
id=
"viewport"
content=
"width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no"
name=
"viewport"
/>
<meta
id=
"viewport"
content=
"width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no"
name=
"viewport"
/>
<!-- <meta name="viewport" content="width=device-width, initial-scale=1.0 user-scalable=yes" /> -->
<!-- <meta name="viewport" content="width=device-width, initial-scale=1.0 user-scalable=yes" /> -->
<link
rel=
"icon"
href=
"<%= BASE_URL %>favicon.ico"
>
<link
rel=
"icon"
href=
"<%= BASE_URL %>favicon.ico"
>
<title>
...
</title>
<title>
...
</title>
</head>
</head>
<body>
<body>
<noscript>
<noscript>
<strong>
We're sorry but mobile-h5-new doesn't work properly without JavaScript enabled. Please enable it to continue.
</strong>
<strong>
We're sorry but mobile-h5-new doesn't work properly without JavaScript enabled. Please enable it to
</noscript>
continue.
</strong>
<div
id=
"app"
></div>
</noscript>
<script>
<div
id=
"app"
></div>
var
width
=
window
.
screen
.
width
<script>
document
.
getElementsByTagName
(
'html'
)[
0
].
style
.
fontSize
=
width
/
7.5
+
'px'
;
// var width = window.screen.width
// 如上:通过查询屏幕宽度,动态的设置 html 的 font-size 值,设计稿大多以 750*1334 设置的,通过上述换算后,在设计图上一张 150*150 的图,在css中对应的 rem 值则为:1.5*1.5 rem
// document.getElementsByTagName('html')[0].style.fontSize = width / 7.5 + 'px';
</script>
// 如上:通过查询屏幕宽度,动态的设置 html 的 font-size 值,设计稿大多以 750*1334 设置的,通过上述换算后,在设计图上一张 150*150 的图,在css中对应的 rem 值则为:1.5*1.5 rem
<!-- <script src="http://mozilla.github.io/pdf.js/build/pdf.js"></script> -->
<!-- <script src="./static/pdf.js"></script> -->
(
function
(
doc
,
win
)
{
</body>
// 用原生方法获取用户设置的浏览器的字体大小(兼容ie)
if
(
doc
.
documentElement
.
currentStyle
)
{
var
user_webset_font
=
doc
.
documentElement
.
currentStyle
[
'fontSize'
];
}
else
{
var
user_webset_font
=
getComputedStyle
(
doc
.
documentElement
,
false
)[
'fontSize'
];
}
// 取整后与默认16px的比例系数
var
xs
=
parseFloat
(
user_webset_font
)
/
16
;
// 设置rem的js设置的字体大小
var
view_jsset_font
,
result_font
;
var
docEl
=
doc
.
documentElement
,
resizeEvt
=
'orientationchange'
in
window
?
'orientationchange'
:
'resize'
,
clientWidth
,
recalc
=
function
()
{
clientWidth
=
docEl
.
clientWidth
;
if
(
!
clientWidth
)
return
;
if
(
!
doc
.
addEventListener
)
return
;
if
(
clientWidth
<
750
)
{
// 设置rem的js设置的字体大小
view_jsset_font
=
100
*
(
clientWidth
/
750
);
// 最终的字体大小为rem字体/系数
result_font
=
view_jsset_font
/
xs
;
// 设置根字体大小
docEl
.
style
.
fontSize
=
result_font
+
'px'
;
}
else
{
docEl
.
style
.
fontSize
=
100
+
'px'
;
}
};
win
.
addEventListener
(
resizeEvt
,
recalc
,
false
);
doc
.
addEventListener
(
'DOMContentLoaded'
,
recalc
,
false
);
})(
document
,
window
);
</script>
<!-- <script src="http://mozilla.github.io/pdf.js/build/pdf.js"></script> -->
<!-- <script src="./static/pdf.js"></script> -->
</body>
</html>
</html>
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment