Commit 2e866f7c authored by xinzhedeai's avatar xinzhedeai

yh

parent 163efa62
......@@ -2,6 +2,40 @@
var docEl = document.documentElement
var dpr = window.devicePixelRatio || 1
// 获取当前值
const dpr11 = window.devicePixelRatio;
console.log(`设备像素比:${dpr11}`);
function getBrowserInfo() {
const userAgent = navigator.userAgent.toLowerCase();
console.log(userAgent)
let browser = 'Unknown';
// 主流浏览器判断
if (userAgent.includes('edg/')) {
browser = 'Microsoft Edge';
} else if (userAgent.includes('chrome')) {
browser = 'Chrome';
} else if (userAgent.includes('firefox')) {
browser = 'Firefox';
} else if (userAgent.includes('safari')) {
browser = 'Safari';
} else if (userAgent.includes('trident') || userAgent.includes('msie')) {
browser = 'Internet Explorer';
}
// 版本号提取(示例:Chrome/120.0.0.0)
const versionMatch = userAgent.match(/(edg|chrome|firefox|safari|version|rv:)[\s\/:]([\d.]+)/i);
const version = versionMatch ? versionMatch[2] : 'Unknown';
return { browser, version };
}
// 打印日志
const browserInfo = getBrowserInfo();
console.log(`浏览器:${browserInfo.browser},版本:${browserInfo.version}`);
// adjust body font size
function setBodyFontSize () {
if (document.body) {
......@@ -16,6 +50,7 @@
// set 1rem = viewWidth / 7.5 // 使用7.5, 使得在750px的设计稿中,1rem = 100px换算十分方便!!!!!!!!
function setRemUnit () {
var rem = docEl.clientWidth / 7.5
console.log('rem', rem)
docEl.style.fontSize = rem + 'px'
}
......
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment