Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
div (レイヤーなど) があり、解像度の低い訪問者に問題があります。div の高さがページ ビューポートよりも大きいかどうかをテストする簡単な方法はありますか? はいの場合は、div をビューポートの上部に移動しますか? ありがとう
これを試してください:
(function () { var viewport = window.innerWidth, el = document.getElementById('myDiv'), widthDiv = el.style.width; if (widthDiv > viewport) { // Move the div higher el.style.zIndex = 999; } }())