第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

如何僅在具有一定寬度的屏幕上顯示 JS

如何僅在具有一定寬度的屏幕上顯示 JS

猛跑小豬 2022-12-22 09:45:37
我正在使用以下代碼屏幕更大 999px<script>    if ((window.innerWidth || document.documentElement.clientWidth || document.body.clientWidth) >= 999) {        // Show on screens bigger than 999px    }</script>屏幕小于 767px<script>    if ((window.innerWidth || document.documentElement.clientWidth || document.body.clientWidth) < 767) {        // Show on screens smaller than 767px    }</script>現在我的目標是顯示 970 到 768 之間的東西我已經嘗試了下面的代碼,但這在 767px 以下也可見<script>    if ((window.innerWidth || document.documentElement.clientWidth || document.body.clientWidth) < 970) {        // Show on screens from 970 till 768    }</script>我如何設置它只顯示在 970 到 768 的屏幕上?我不會使用 CSS。
查看完整描述

2 回答

?
陪伴而非守候

TA貢獻1757條經驗 獲得超8個贊

const width = window.innerWidth || document.documentElement.clientWidth || document.body.clientWidth;


if( width >=768 && width <= 970){

    // do what you need

}

邏輯與 (&&)


查看完整回答
反對 回復 2022-12-22
?
小怪獸愛吃肉

TA貢獻1852條經驗 獲得超1個贊

let width = window.innerWidth || document.documentElement.clientWidth || document.body.clientWidth;


if( width >=768 && width <= 970){

    // Show on screens between 768 and 970 px

}

else if (width < 768){

    // Show on screens smaller than 768px


}

else if (width > 970){

    // Show on screens bigger than 970px

}

else {

   // Show other cases


}


查看完整回答
反對 回復 2022-12-22
  • 2 回答
  • 0 關注
  • 85 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號