比如这个页面的“隐藏侧边栏”
http://bbs.csdn.net/
给个源码看看
回复讨论(解决方案)
其实就是设置 css,显示style.display='block',隐藏style.display='node'
我写了个例子,与csdn的实现方式可能不一样
<style> html,body{ width:100%;height:100%;padding:0px;margin:0px;overflow:hidden } #ifr1{height:100%;width:200px;float:left; } #ifr2{height:100%;width:100px float:right; } #hand{ position: absolute; z-index: 99; left: 200px; top: 48%; height: 50px; word-break: break-all; display: block; width: 20px; background: #fff; text-align: center; border: 1px solid #ccf; } </style> <iframe id="ifr1" src="http://bbs.csdn.net/left_menu"></iframe> <iframe id="ifr2" src="http://bbs.csdn.net/home"></iframe> <div id="hand" >隐藏</div> <script> function $(id){return document.getElementById(id) } var w,hand=$('hand'),ifr1=$('ifr1'),ifr2=$('ifr2'); hand.onclick=function(){ //点击隐藏按钮 var sty=ifr1.style,disp; sty.display=sty.display=='none'?'block':'none'; doResize(); } function doResize(){ //调整位置大小 var w=document.body.clientWidth; var sty=ifr1.style,disp; if(sty.display=='none'){ ifr2.style.width='100%'; hand.style.left='1px'; }else{ ifr2.style.width=w-220+'px'; hand.style.left='200px'; } } window.onload=window.onresize=doResize; doResize() </script>
csdn用的是frameset,设置其中framset的cols属性为0,*收缩导航,设置为230,*展开导航
我这样写为什么“隐藏”按钮不显示?
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>左右布局侧边栏演示</title> <link href="http://csdnimg.cn/www/images/favicon.ico" rel="SHORTCUT ICON"><style> //html,body{ width:100%;height:100%;padding:0px;margin:0px;overflow:hidden } //#ifr1{height:100%;width:200px;float:left; } //#ifr2{height:100%;width:100px float:right; } #hand{ position: absolute; // 绝对定位 z-index: 10001; // 优先级最高(离用户最近) left: 200px; top: 48%; height: 50px; word-break: break-all; display: block; width: 20px; //background: #fff; text-align: center; border: 1px solid #ccf; } </style> </head> <frameset cols="230,*" frameborder="no" border="0" framespacing="0"> <frame src="左右框架窗体1.html" name="leftFrame" noresize="noresize" id="ifr1" title="leftFrame" /> <frame src="左右框架窗体1.html" name="mainFrame" id="ifr2" title="mainFrame" /> </frameset> <noframes> <div id="hand" >隐藏</div><script> function $(id){ return document.getElementById(id) } var w,hand=$('hand'),ifr1=$('ifr1'),ifr2=$('ifr2'); hand.onclick=function(){ //点击隐藏按钮 var sty=ifr1.style,disp; sty.display=sty.display=='none'?'block':'none'; doResize(); } function doResize(){ //调整位置大小 var w=document.body.clientWidth; var sty=ifr1.style,disp; if(sty.display=='none'){ ifr2.style.width='100%'; hand.style.left='1px'; }else{ ifr2.style.width=w-220+'px'; hand.style.left='200px'; } } window.onload=window.onresize=doResize; doResize() </script> <body> </body> </noframes></html>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>CSDN论坛首页 - CSDN.NET</title> <script src="/assets/application-1a33bfd3d5ee7e433197442aeb9c03b6.js" type="text/javascript"></script> <script type="text/javascript"> $(function() { main_page_js.index_page(); }); </script> <link href="http://csdnimg.cn/www/images/favicon.ico" rel="SHORTCUT ICON"> </head> <frameset cols="230,*" frameborder="no" border="0" framespacing="0"> <frame src="/left_menu" name="leftFrame" noresize="noresize" id="leftFrame" title="leftFrame" /> <frame src="/home" name="mainFrame" id="mainFrame" title="mainFrame" /> </frameset> <noframes> <body> </body> </noframes></html>
我研究了各位老大的方法,结果死活只在IE里才好用,其它的遨游、谷歌之类的点击了都没有反应,代码如下:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>左右布局侧边栏演示</title> </head><frameset rows="*" name="top_function" id="top_function" frameborder="NO" border="0" framespacing="0"> <frameset cols="20%,20,*" name="left_function" id="left_function" frameborder="NO" border="0" framespacing="0"> <frame src="left.html" name="leftFrame" id="leftFrame" title="leftFrame" /><frame src="left_close.html" name="left_close" id="left_close" scrolling="NO" noresize="noresize" title="left_close" style="border-color:#FF0000; border-style:solid; border-width:1px; padding-right:2" /> <frame src="right.html" name="mainFrame" id="mainFrame" title="mainFrame" /> </frameset></frameset> <noframes> <body><p>此网页使用了框架,但您的浏览器不支持框架。</p> </body> </noframes></html>
left_close.html文件在这里,和上面的放在一个目录里:
<html><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8" /><title>关闭和显示侧边栏</title><SCRIPT LANGUAGE="javascript"><!--function shleft(){ if (parent.left_function.cols!="20%,20,*"){ parent.left_function.cols="20%,20,*" } else{ parent.left_function.cols="0,20,*" }}//--></SCRIPT></head><body onclick="shleft();"></body></html>
各位老大帮忙看看吧!拜托了!
这个也没有效果:
if (parent.document.getElementById('top_function').rows!='10%,20,*'){ parent.document.getElementById('top_function').rows='10%,20,*' }else{ parent.document.getElementById('top_function').rows='0,20,*' }
、脚本写最简单吧,。。。

HTML的作用是通過標籤和屬性定義網頁的結構和內容。 1.HTML通過到、等標籤組織內容,使其易於閱讀和理解。 2.使用語義化標籤如、等增強可訪問性和SEO。 3.優化HTML代碼可以提高網頁加載速度和用戶體驗。

htmlisaspecifictypefodyfocusedonstructuringwebcontent,而“代碼” badlyLyCludEslanguagesLikeLikejavascriptandPytyPythonForFunctionality.1)htmldefineswebpagertuctureduseTags.2)“代碼”代碼“ code” code code code codeSpassSesseseseseseseseAwiderRangeLangeLangeforLageforLogageforLogicIctInterract

HTML、CSS和JavaScript是Web開發的三大支柱。 1.HTML定義網頁結構,使用標籤如、等。 2.CSS控製網頁樣式,使用選擇器和屬性如color、font-size等。 3.JavaScript實現動態效果和交互,通過事件監聽和DOM操作。

HTML定義網頁結構,CSS負責樣式和佈局,JavaScript賦予動態交互。三者在網頁開發中各司其職,共同構建豐富多彩的網站。

HTML適合初學者學習,因為它簡單易學且能快速看到成果。 1)HTML的學習曲線平緩,易於上手。 2)只需掌握基本標籤即可開始創建網頁。 3)靈活性高,可與CSS和JavaScript結合使用。 4)豐富的學習資源和現代工具支持學習過程。

AnexampleOfAstartingTaginHtmlis,beginSaparagraph.startingTagSareEssentialInhtmlastheyInitiateEllements,defiteTheeTheErtypes,andarecrucialforsstructuringwebpages wepages webpages andConstructingthedom。

如何設計菜單中的虛線分割效果?在設計菜單時,菜名和價格的左右對齊通常不難實現,但中間的虛線或點如何...

網頁代碼編輯器中的HTML元素分析許多在線代碼編輯器允許用戶輸入HTML、CSS和JavaScript代碼。最近,有人提出了一...


熱AI工具

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

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

Undress AI Tool
免費脫衣圖片

Clothoff.io
AI脫衣器

AI Hentai Generator
免費產生 AI 無盡。

熱門文章

熱工具

ZendStudio 13.5.1 Mac
強大的PHP整合開發環境

Atom編輯器mac版下載
最受歡迎的的開源編輯器

Safe Exam Browser
Safe Exam Browser是一個安全的瀏覽器環境,安全地進行線上考試。該軟體將任何電腦變成一個安全的工作站。它控制對任何實用工具的訪問,並防止學生使用未經授權的資源。

SublimeText3 Linux新版
SublimeText3 Linux最新版

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