35 lines
1.4 KiB
JavaScript
35 lines
1.4 KiB
JavaScript
|
|
// (function (doc, win) {
|
||
|
|
// var docEl = doc.documentElement
|
||
|
|
// var resizeEvt = 'orientationchange' in window ? 'orientationchange' : 'resize'
|
||
|
|
// var recalc = function () {
|
||
|
|
// var clientWidth = docEl.clientWidth
|
||
|
|
// if (!clientWidth) return
|
||
|
|
// docEl.style.fontSize = 100 * (clientWidth / 1920) + 'px'
|
||
|
|
// document.body.style.display = 'block'
|
||
|
|
// }
|
||
|
|
// if (!doc.addEventListener) return win.addEventListener(resizeEvt, recalc, false)
|
||
|
|
// doc.addEventListener('DOMContentLoaded', recalc, false)
|
||
|
|
// })(document, window)
|
||
|
|
|
||
|
|
(function () {
|
||
|
|
var _self = this
|
||
|
|
_self.width = 1920
|
||
|
|
_self.fontSize = 100
|
||
|
|
_self.widthProportion = function () {
|
||
|
|
var p = ((document.body && document.body.clientWidth) || document.getElementsByTagName('html')[0].offsetWidth) / _self.width
|
||
|
|
return p
|
||
|
|
}
|
||
|
|
_self.changePage = function () {
|
||
|
|
document.getElementsByTagName('html')[0].setAttribute('style', 'font-size:' + _self.widthProportion() * _self.fontSize + 'px')
|
||
|
|
}
|
||
|
|
_self.changePage()
|
||
|
|
window.addEventListener('resize', function () {
|
||
|
|
let clientWidth = ((document.body && document.body.clientWidth) || document.getElementsByTagName('html')[0].offsetWidth)
|
||
|
|
if (clientWidth >= 1550) {
|
||
|
|
_self.changePage()
|
||
|
|
} else {
|
||
|
|
document.getElementsByTagName('html')[0].setAttribute('style', 'font-size:' + 1550 / _self.width * _self.fontSize + 'px')
|
||
|
|
}
|
||
|
|
}, false)
|
||
|
|
})()
|