CSDN的隐藏侧边栏功能是怎么实现的?_html/css_WEB-ITnose
比如这个页面的“隐藏侧边栏”
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,*' }
、脚本写最简单吧,。。。

핫 AI 도구

Undresser.AI Undress
사실적인 누드 사진을 만들기 위한 AI 기반 앱

AI Clothes Remover
사진에서 옷을 제거하는 온라인 AI 도구입니다.

Undress AI Tool
무료로 이미지를 벗다

Clothoff.io
AI 옷 제거제

AI Hentai Generator
AI Hentai를 무료로 생성하십시오.

인기 기사

뜨거운 도구

메모장++7.3.1
사용하기 쉬운 무료 코드 편집기

SublimeText3 중국어 버전
중국어 버전, 사용하기 매우 쉽습니다.

스튜디오 13.0.1 보내기
강력한 PHP 통합 개발 환경

드림위버 CS6
시각적 웹 개발 도구

SublimeText3 Mac 버전
신 수준의 코드 편집 소프트웨어(SublimeText3)

뜨거운 주제











이 기사는 HTML & lt; Progress & Gt에 대해 설명합니다. 요소, 그 목적, 스타일 및 & lt; meter & gt의 차이; 요소. 주요 초점은 & lt; progress & gt; 작업 완료 및 & lt; meter & gt; Stati의 경우

이 기사는 HTML & LT; Datalist & GT에 대해 논의합니다. 자동 완성 제안을 제공하고, 사용자 경험을 향상시키고, 오류를 줄임으로써 양식을 향상시키는 요소. 문자 수 : 159

기사는 HTML5 크로스 브라우저 호환성을 보장하기위한 모범 사례에 대해 논의하고 기능 감지, 점진적 향상 및 테스트 방법에 중점을 둡니다.

이 기사는 HTML & lt; meter & gt에 대해 설명합니다. 범위 내에 스칼라 또는 분수 값을 표시하는 데 사용되는 요소 및 웹 개발의 일반적인 응용 프로그램. & lt; meter & gt; & lt; Progress & Gt; 그리고 Ex

이 기사는 html5 & lt; time & gt; 시맨틱 날짜/시간 표현 요소. 인간이 읽을 수있는 텍스트와 함께 기계 가독성 (ISO 8601 형식)에 대한 DateTime 속성의 중요성을 강조하여 Accessibilit를 향상시킵니다.

이 기사에서는 브라우저에서 직접 사용자 입력을 검증하기 위해 필요한, Pattern, Min, Max 및 Length 한계와 같은 HTML5 양식 검증 속성을 사용하는 것에 대해 설명합니다.

이 기사는 모바일 장치의 반응 형 웹 디자인에 필수적인 Viewport Meta Tag에 대해 설명합니다. 적절한 사용이 최적의 컨텐츠 스케일링 및 사용자 상호 작용을 보장하는 방법을 설명하는 반면, 오용은 설계 및 접근성 문제로 이어질 수 있습니다.

이 기사는 & lt; iframe & gt; 외부 컨텐츠를 웹 페이지, 공통 용도, 보안 위험 및 객체 태그 및 API와 같은 대안을 포함시키는 태그의 목적.
