分享一個html Div層的展開與縮小的特效原始碼
html Div層的展開與縮略的特效原始碼,以下小編帶你們來了解
<html> <head> <title>p展开收缩代码-www.zuidaima.com-最代码</title> <style> * { margin:0; padding:0;} body { text-align:center; font:75% Verdana, Arial, Helvetica, sans-serif;} h1 { font:125% Arial, Helvetica, sans-serif; text-align:left; font-weight:bolder; background:#333; padding:3px; display:block; color:#99CC00} .class1 { width:40%; background:#CCC; position:relative; margin:0 auto; padding:5px;} span { position:absolute; right:10px; top:8px; cursor: pointer; color:yellow;} p { text-align:left; line-height:20px; background:#333; padding:3px; margin-top:5px; color:#99CC00} #class1content, #class2content,#class3content { height:50px;overflow:hidden;display:none;} </style> <script> function $(element){ return element = document.getElementById(element); } function $D(element){ var d=$(element); var h=d.offsetHeight; var maxh=300; function dmove(){ if(h>=maxh){ d.style.height='300px'; clearInterval(iIntervalId); }else{ h+=50; //设置层展开的速度 d.style.display='block'; d.style.height=h+'px'; } } iIntervalId=setInterval(dmove,2); } function $D2(element){ var d=$(element); var h=d.offsetHeight; var maxh=300; function dmove(){ if(h<=0){ d.style.display='none'; clearInterval(iIntervalId); }else{ h-=50;//设置层收缩的速度 d.style.height=h+'px'; } } iIntervalId=setInterval(dmove,2); } function $use(targetid,objN){ var d=$(targetid); var sb=$(objN); if (d.style.display=="block"){ $D2(targetid); d.style.display="none"; sb.innerHTML="展开"; } else { var p=document.getElementsByTagName("p"); var span=document.getElementsByTagName("span"); for(var i=0,l=p.length;i<l;i++){ if(p[i]!=d){ p[i].style.height=0; p[i].style.display="none"; span[i].innerHTML="展开"; } } $D(targetid); d.style.display="block"; sb.innerHTML='收缩'; } } </script> </head> <body> <p class="class1"> <h1>p展开收缩效果</h1> <span id="stateBut" onClick="$use('class1content','stateBut')">展开</span> <p id="class1content">something.........</p> </p> <p class="class1"> <h1>p展开收缩效果</h1> <span id="stateBut1" onClick="$use('class2content','stateBut1')">展开</span> <p id="class2content">something.........</p> </p> <p class="class1"> <h1>p展开收缩效果</h1> <span id="stateBut2" onClick="$use('class3content','stateBut2')">展开</span> <p id="class3content">wojiade</p> </p> </body> </html>
以上是分享一個html Div層的展開與縮小的特效原始碼的詳細內容。更多資訊請關注PHP中文網其他相關文章!

熱AI工具

Undress AI Tool
免費脫衣圖片

Undresser.AI Undress
人工智慧驅動的應用程序,用於創建逼真的裸體照片

AI Clothes Remover
用於從照片中去除衣服的線上人工智慧工具。

Clothoff.io
AI脫衣器

Video Face Swap
使用我們完全免費的人工智慧換臉工具,輕鬆在任何影片中換臉!

熱門文章

熱工具

記事本++7.3.1
好用且免費的程式碼編輯器

SublimeText3漢化版
中文版,非常好用

禪工作室 13.0.1
強大的PHP整合開發環境

Dreamweaver CS6
視覺化網頁開發工具

SublimeText3 Mac版
神級程式碼編輯軟體(SublimeText3)

要為網站標題欄添加圖標,需在HTML的部分鏈接一個favicon文件,具體步驟如下:1.準備一個16x16或32x32像素的圖標文件,推薦使用favicon.ico命名並放置於網站根目錄,或使用PNG、SVG等現代格式;2.在HTML的中添加鏈接標籤,如,若使用PNG或SVG格式則相應調整type屬性;3.可選地為移動設備添加高分辨率圖標,如AppleTouchIcon,並通過sizes屬性指定不同尺寸;4.遵循最佳實踐,將圖標置於根目錄以確保自動檢測,更新後清除瀏覽器緩存,檢查文件路徑正確性,

首先檢查src屬性路徑是否正確,確保相對路徑或絕對路徑與HTML文件位置匹配;2.核實文件名和擴展名是否拼寫正確且區分大小寫;3.確認圖像文件實際存在於指定目錄中;4.使用合適的alt屬性並確保圖像格式為瀏覽器廣泛支持的.jpg、.png、.gif或.webp;5.排除瀏覽器緩存問題,嘗試強制刷新或直接訪問圖像URL;6.檢查服務器權限設置,確保文件可被讀取且未被屏蔽;7.驗證img標籤語法正確,包含正確的引號和屬性順序,最終通過瀏覽器開發者工具排查404錯誤或語法問題以確保圖像正常顯示。

Thetagisusedtomarkdeletedtext,optionallywithdatetimeandciteattributestospecifywhenandwhythedeletionoccurred.2.Thetagindicatesinsertedcontent,alsosupportingdatetimeandciteforcontextabouttheaddition.3.Thesetagscanbecombinedtoshowdocumentrevisionsclearl

是的,可以通過使用contenteditable屬性使HTML元素可編輯,具體方法是添加contenteditable="true"到目標元素上,例如你可編輯此文本,此時用戶可直接點擊並修改內容;該屬性適用於div、p、span、h1至h6等塊級和行內元素;默認值為"true"表示可編輯,"false"表示不可編輯,"inherit"表示繼承父元素設置;為提升可訪問性,建議添加tabindex="0&quo

theasyncattributeinhtmlisusedtoloadandexecuteexternaljavascriptFileSsynChronChonChonChonChonChonChonChrone,browsertodownloadthescriptInparallelwithhtmlparSinghtmlparsinghthtmlparsingandexecuteItimmedimmeduponMmeduponComcompoineponcomcompoineponcomcompoineponcomcompletion

要為HTMLselect元素設置默認值,必須使用selected屬性標記對應的option元素;1.將selected屬性添加到希望默認選中的option上,如UnitedStates;2.確保單個select中僅有一個option帶有selected屬性,若有多個則以源碼順序第一個為準;3.selected屬性可置於列表任意位置,不限於首個option;4.該方法適用於單选和多選select;5.若需動態設置,可用JavaScript操作value屬性,如document.querySelec

thebdotagissusedtooverridethebrowser的sdeftTextDirectionRenderingWhenDealingWithMixedLeftleft to-rightright to-rightright to-leftText,確保correctvisaldisplaybydisplaybyforcingaspecificection asspeciforcection thedirattributewithtributewithvalues“ ltr” ltr ltr或“ rtl” as as as as as as as as derments-

Thetagisusedtodefinecontactinformationfortheauthororownerofadocumentorsection;1.Useitforemail,physicaladdress,phonenumber,orwebsiteURLwithinanarticleorbody;2.Placeitinsideforauthorcontactorinfordocument-widecontact;3.StyleitwithCSSasneeded,notingdefa
