Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

落地页不同手机的诡异表现 #5

Open
PeterChen1997 opened this issue Sep 9, 2019 · 2 comments
Open

落地页不同手机的诡异表现 #5

PeterChen1997 opened this issue Sep 9, 2019 · 2 comments
Labels
bug Something isn't working

Comments

@PeterChen1997
Copy link
Owner

PeterChen1997 commented Sep 9, 2019

表现

落地页在不同手机上出现不同的表现

调查

发现chrome调试的渲染字体大小与实际的font-size不一,搜索发现是由于系统字体放大导致的

解决

< script >
var systemFontSizeAdjustDiv = document.createElement("div");

systemFontSizeAdjustDiv.innerHTML = '<div class="fontsize-adjust" style="width:100%;height:100rem;position:fixed;visibility:hidden;"></div>'

document.body.appendChild(systemFontSizeAdjustDiv);

var testDiv = document.querySelector(".fontsize-adjust"),
currentHeight = testDiv.offsetHeight,
currentFontSize = document.querySelector("html").style.fontSize.slice(0, -2),
originHeight = 100 * document.querySelector("html").style.fontSize.slice(0, -2),

magnifyingTimes = currentHeight / originHeight;

document.querySelector("html").style.fontSize = currentFontSize / magnifyingTimes + "px",
document.body.removeChild(testDiv.parentNode); 
< /script>
@PeterChen1997 PeterChen1997 added the bug Something isn't working label Jul 29, 2020
@PeterChen1997
Copy link
Owner Author

@PeterChen1997
Copy link
Owner Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant