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

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

當(dāng)用戶單擊最大化按鈕時(shí),JavaScript窗口調(diào)整大小事件無法正常工作

當(dāng)用戶單擊最大化按鈕時(shí),JavaScript窗口調(diào)整大小事件無法正常工作

BIG陽 2019-04-26 12:15:26
當(dāng)我單擊瀏覽器窗口的“最大化”按鈕時(shí),我編寫的一個(gè)函數(shù)將在調(diào)整窗口大小時(shí)執(zhí)行,但無法正常工作。當(dāng)我使用鼠標(biāo)調(diào)整窗口大小時(shí),它工作。<div class="div1">    <div class="div2"></div></div>.div1 { position: relative; }.div2 { position: absolute; width: 300px; top: 0; transition: all 0.5s ease; }@media only screen and (max-width: 1024px) { .div2 { width: 200px; } }function aFuntion() {    let div1 = document.querySelector('.div1');    let div2 = document.querySelector('.div2');    let diff = div1.clientHeight - div2.clientHeight;    div1.style.top = -diff + 10 + 'px';};// Call the function.// This worked!aFuntion();// Call the function when users resize the window.// This worked!window.addEventListener('resize', aFuntion);// Users click on the Maximize button of the window.// The function does not work!
查看完整描述

3 回答

?
森欄

TA貢獻(xiàn)1810條經(jīng)驗(yàn) 獲得超5個(gè)贊

我已經(jīng)在Firefox,Chrome和Internet Explorer中測試了下面的代碼,它正在按預(yù)期工作。我知道這是一種解決方法,因?yàn)槭录菑腷ody標(biāo)簽觸發(fā)的,但也許它會對你有所幫助。


<html>

<head>

<script>

function resizeFunction() {

    console.log("working");

}

</script>

</head>

<body onresize="resizeFunction()">

content

</body>

</html>


查看完整回答
反對 回復(fù) 2019-05-17
?
慕婉清6462132

TA貢獻(xiàn)1804條經(jīng)驗(yàn) 獲得超2個(gè)贊

好的。我解決了自己的問題。以某種方式過渡:全部0.5秒輕松; 調(diào)整大小不起作用。我刪除了轉(zhuǎn)換:所有0.5秒輕松; 它起作用了。


查看完整回答
反對 回復(fù) 2019-05-17
?
FFIVE

TA貢獻(xiàn)1797條經(jīng)驗(yàn) 獲得超6個(gè)贊

嘗試 document.addEventListener('resize', aFuntion);


查看完整回答
反對 回復(fù) 2019-05-17
  • 3 回答
  • 0 關(guān)注
  • 508 瀏覽
慕課專欄
更多

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號