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

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

顯示 Div、設(shè)置超時(shí)、隱藏 Div

顯示 Div、設(shè)置超時(shí)、隱藏 Div

DIEA 2023-06-09 14:41:39
單擊 div 時(shí),應(yīng)出現(xiàn)一個(gè)圖像,3 秒后再次消失。該函數(shù)的第一行讓它出現(xiàn),但如果我添加超時(shí),則單擊圖像時(shí)不會(huì)發(fā)生任何事情。我該如何解決?(另外,如果有人可以包括我如何讓心臟出現(xiàn)在#stickycat div 的中心,請(qǐng)這樣做!)function heart() {    document.getElementById("heart").style.display = "block"    setTimeout(fn(){ document.getElementById("heart").style.display = "none"}, 3000)}#stickycat {    position: fixed;    bottom:10px;    right: 10px;    width:100px;    height:100px;    border-radius:50%;    border: solid 4px rgba(54, 215, 183, 1);    background-color:white;    text-align:center;    box-shadow: 1px 1px 10px rgba(54, 215, 183, 1), -1px 1px 10px rgba(54, 215, 183, 1), -1px -1px 10px rgba(54, 215, 183, 1), 1px -1px 10px rgba(54, 215, 183, 1);}#stickycat img {    max-width:100%;    max-height:100%;    z-index:2;    border-radius:50%;}#heart {    animation: pulse 2s linear infinite;    position:absolute;    width:50px;    height:50px;    display:none;}@keyframes pulse {    0% { transform: scale(1); }    50% { transform: scale(1.3); }    100% { transform: scale(1); }}<div id="stickycat" onclick="heart()"><img src="https://i.pinimg.com/originals/9d/b1/3f/9db13f4f06bfa1600e970fd32f1851db.gif"><img id="heart" src="https://upload.wikimedia.org/wikipedia/commons/thumb/f/f1/Heart_coraz%C3%B3n.svg/1200px-Heart_coraz%C3%B3n.svg.png"></div>
查看完整描述

1 回答

?
萬(wàn)千封印

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

首先,fn()不是一種聲明函數(shù)的方法。您可以使用function()關(guān)鍵字聲明匿名函數(shù)。


position心的屬性設(shè)置為absolute。因此居中部分可以通過(guò)使用top和leftcss 屬性來(lái)管理。


下面是工作示例。


function heart() {

    document.getElementById("heart").style.display = "block"

    setTimeout(function(){ document.getElementById("heart").style.display = "none"}, 3000);

}

  #stickycat {

    position: fixed;

    bottom:10px;

    right: 10px;

    width:100px;

    height:100px;

    border-radius:50%;

    border: solid 4px rgba(54, 215, 183, 1);

    background-color:white;

    text-align:center;

    box-shadow: 1px 1px 10px rgba(54, 215, 183, 1), -1px 1px 10px rgba(54, 215, 183, 1), -1px -1px 10px rgba(54, 215, 183, 1), 1px -1px 10px rgba(54, 215, 183, 1);

  }

  #stickycat img {

    max-width:100%;

    max-height:100%;

    z-index:2;

    border-radius:50%;

  }

  #heart {

    animation: pulse 2s linear infinite;

    position:absolute;

    top: 25px;

    left: 25px;

    width:50px;

    height:50px;

    display:none;

  }

  @keyframes pulse {

    0% { transform: scale(1); }

    50% { transform: scale(1.3); }

    100% { transform: scale(1); }

  }

<div id="stickycat" onclick="heart()">

  <img src="https://i.pinimg.com/originals/9d/b1/3f/9db13f4f06bfa1600e970fd32f1851db.gif">

  <img id="heart" src="https://upload.wikimedia.org/wikipedia/commons/thumb/f/f1/Heart_coraz%C3%B3n.svg/1200px-Heart_coraz%C3%B3n.svg.png">

</div>


查看完整回答
反對(duì) 回復(fù) 2023-06-09
  • 1 回答
  • 0 關(guān)注
  • 145 瀏覽
慕課專欄
更多

添加回答

舉報(bào)

0/150
提交
取消
微信客服

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

幫助反饋 APP下載

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

公眾號(hào)

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