代码
提交代码
<style>
.outer { position: fixed; top: 0; left: 0; right: 0; bottom: 0; background:rgb(0, 0, 0); }
.outer .text { position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); color: white; font-size: 100px; text-shadow: 0 0 5px #fff, 0 0 10px #fff, 0 0 15px #fff, 0 0 20px #FF1177, 0 0 35px #FF1177, 0 0 40px #FF1177, 0 0 50px #FF1177, 0 0 75px #FF1177; }
</style>
<div class="outer">
<div class="text"></div>
</div>
<script>
var text = document.querySelector('.text');
var timer = false;
var resize = function() {
if (timer) return; // 判断是不是上一次事件执行完300毫秒内
var height = window.innerHeight;
var width = window.innerWidth;
text.innerText = width + 'x' + height;
timer = setTimeout(function () {
timer = null;
}, 300);
};
window.addEventListener('resize', resize);
resize();
</script>
运行结果