how2j.cn

"); window.frames["iframe_toc"+sid].document.write(decodeHtml($("pre#stepCodePre"+sid).html())); window.frames["iframe_toc"+sid].document.close(); $(window.frames["iframe_toc"+sid]).load(function(){ $("#iframe_toc"+sid).height($("#iframe_toc"+sid).contents().find("body").height()+(showittryitheight)); }); $("#iframe_toc"+sid).height($("#iframe_toc"+sid).contents().find("body").height()+(showittryitheight)); } $("input.tocName").hover(function(){ $(this).select(); }); function refresh(){ var sid = tocstepids.shift(); if(null!=sid) refreshIframe(sid); else go2ArchorFlag = true; } var t = setInterval(refresh,300); // $("div.steptoc iframe").height($(showittryitheight+50)); });
效果 说明 示例代码
<!DOCTYPE html>
<script src="http://127.0.0.1/study../../../js/jquery/2.0.0/jquery.min.js"></script>
<link href="http://127.0.0.1/study../../../css/bootstrap/3.3.6/bootstrap.min.css" rel="stylesheet">
<script src="http://127.0.0.1/study../../../js/bootstrap/3.3.6/bootstrap.min.js"></script>
<body>
<style>
p{

  margin-left:10px;
  margin-top:10px;
}
</style>
<ul id="myTab" class="nav nav-tabs">
   <li class="active">
      <a href="#dota" data-toggle="tab">
         DotA
      </a>
   </li>
   <li><a href="#lol" data-toggle="tab">英雄联盟</a></li>
   <li class="dropdown">
      <a href="#" id="myTabDrop1" class="dropdown-toggle" 
         data-toggle="dropdown">其他类似游戏 
         <b class="caret"></b>
      </a>
      <ul class="dropdown-menu" role="menu" aria-labelledby="myTabDrop1">
         <li><a href="#storm" tabindex="-1" data-toggle="tab">风暴英雄</a></li>
         <li><a href="#h300" tabindex="-1" data-toggle="tab">300英雄</a></li>
      </ul>
   </li>
</ul>
<div id="myTabContent" class="tab-content">
   <div class="tab-pane fade in active" id="dota">
      <p>《DotA》(Defense of the Ancients),可以译作守护古树、守护遗迹、远古遗迹守卫, 是由暴雪公司出品即时战略游戏《魔兽争霸3》的一款多人即时对战、自定义地图,可支持10个人同时连线游戏,是暴雪公司官方认可的魔兽争霸的RPG地图。</p>
   </div>
   <div class="tab-pane fade" id="lol">
      <p>《英雄联盟》(简称lol)是由美国Riot Games开发,中国大陆地区由腾讯游戏运营的网络游戏。</p>
   </div>
   <div class="tab-pane fade" id="storm">
      <p>
      《风暴英雄》 是由暴雪娱乐公司开发的一款运行在Windows和Mac OS上的在线多人竞技PC游戏。</p>
       <p> 游戏中的英雄角色主要来自于暴雪三大经典游戏系列:《魔兽世界》、《暗黑破坏神》和《星际争霸》。它是一款道具收费的游戏,与《星际争霸Ⅱ》基于同一引擎开发。
      </p>
   </div>
   <div class="tab-pane fade" id="h300">
      <p>《300英雄》是由上海跳跃网络科技有限公司自主研发,深圳中青宝互动网络股份有限公司运营的一款类DOTA网游。游戏以7v7组队对抗玩法为主,提供永恒战场和永恒竞技场两种经典模式任由玩家选择,并创新性地加入勇者斗恶龙、克隆战争等多种休闲娱乐玩法。
      </p>
   </div>
</div>

<div style="height:200px"></div>
可切换导航栏
示例代码

示例 1 :

可切换导航栏

可切换导航栏
"); window.frames["iframe_show3009"].document.write(decodeHtml($("textarea#stepcodeTextarea3009").val())); window.frames["iframe_show3009"].document.close(); $(window.frames["iframe_show3009"]).load(function(){ $("#iframe_show3009").height($("#iframe_show3009").contents().find("body").height()+showittryitheight); }); $("#iframe_show3009").height($("#iframe_show3009").contents().find("body").height()+showittryitheight); setTimeout(function(){ },500); });
运行效果
<!DOCTYPE html> <script src="http://127.0.0.1/study../../../js/jquery/2.0.0/jquery.min.js"></script> <link href="http://127.0.0.1/study../../../css/bootstrap/3.3.6/bootstrap.min.css" rel="stylesheet"> <script src="http://127.0.0.1/study../../../js/bootstrap/3.3.6/bootstrap.min.js"></script> <body> <style> p{ margin-left:10px; margin-top:10px; } </style> <ul id="myTab" class="nav nav-tabs"> <li class="active"> <a href="#dota" data-toggle="tab"> DotA </a> </li> <li><a href="#lol" data-toggle="tab">英雄联盟</a></li> <li class="dropdown"> <a href="#" id="myTabDrop1" class="dropdown-toggle" data-toggle="dropdown">其他类似游戏 <b class="caret"></b> </a> <ul class="dropdown-menu" role="menu" aria-labelledby="myTabDrop1"> <li><a href="#storm" tabindex="-1" data-toggle="tab">风暴英雄</a></li> <li><a href="#h300" tabindex="-1" data-toggle="tab">300英雄</a></li> </ul> </li> </ul> <div id="myTabContent" class="tab-content"> <div class="tab-pane fade in active" id="dota"> <p>《DotA》(Defense of the Ancients),可以译作守护古树、守护遗迹、远古遗迹守卫, 是由暴雪公司出品即时战略游戏《魔兽争霸3》的一款多人即时对战、自定义地图,可支持10个人同时连线游戏,是暴雪公司官方认可的魔兽争霸的RPG地图。</p> </div> <div class="tab-pane fade" id="lol"> <p>《英雄联盟》(简称lol)是由美国Riot Games开发,中国大陆地区由腾讯游戏运营的网络游戏。</p> </div> <div class="tab-pane fade" id="storm"> <p> 《风暴英雄》 是由暴雪娱乐公司开发的一款运行在Windows和Mac OS上的在线多人竞技PC游戏。</p> <p> 游戏中的英雄角色主要来自于暴雪三大经典游戏系列:《魔兽世界》、《暗黑破坏神》和《星际争霸》。它是一款道具收费的游戏,与《星际争霸Ⅱ》基于同一引擎开发。 </p> </div> <div class="tab-pane fade" id="h300"> <p>《300英雄》是由上海跳跃网络科技有限公司自主研发,深圳中青宝互动网络股份有限公司运营的一款类DOTA网游。游戏以7v7组队对抗玩法为主,提供永恒战场和永恒竞技场两种经典模式任由玩家选择,并创新性地加入勇者斗恶龙、克隆战争等多种休闲娱乐玩法。 </p> </div> </div> <div style="height:200px"></div>
"); window.frames["iframe3009"].document.write(decodeHtml(code3009)); window.frames["iframe3009"].document.close(); //load和下面的非load必需并存,因为如果代码用到了jquery就必须使用load的方式 $(window.frames["iframe3009"]).load(function(){ $("#iframe3009").height($("#iframe3009").contents().find("body").height()+showittryitheight); }); $("#iframe3009").height($("#iframe3009").contents().find("body").height()+showittryitheight); alreadyWriteCode3009 = code3009; $("#rendering3009").hide(); $("#rendered3009").show(); } var tRereshRetry2DemoPanel3009 = setInterval(rereshRetry2DemoPanel3009,1000); var binded3009 = false; $("textarea#stepcodeTextarea3009").keyup(function(){ if(!binded3009){ $(window).bind('beforeunload',function(){ binded3009 = true; return "xxxx"; }); } var newCode = $(this).val() code3009 = newCode; /*below code is replaced by function rereshRetry2DemoPanel()*/ // if(code3009!=newCode){ // window.frames["iframe3009"].document.write("
"); // window.frames["iframe3009"].document.write(decodeHtml($("textarea#stepcodeTextarea3009").val())); // window.frames["iframe3009"].document.close(); // $(window.frames["iframe3009"]).load(function(){ // $("#iframe3009").height($("#iframe3009").contents().find("body").height()+showittryitheight); // }); // code3009 = newCode; // } }); $(".tryButton3009").click(function(){ $("#tryDiv3009").show(); $("#stepcodeTextarea3009").focus(); $("#stepcodeTextarea3009").height(200); $("#iframe3009").height(0); window.frames["iframe3009"].document.write("
"); window.frames["iframe3009"].document.write(decodeHtml($("textarea#stepcodeTextarea3009").val())); window.frames["iframe3009"].document.close(); //load和下面的非load必需并存,因为如果代码用到了jquery就必须使用load的方式 $(window.frames["iframe3009"]).load(function(){ $("#iframe3009").height($("#iframe3009").contents().find("body").height()+showittryitheight); }); $("#iframe3009").height($("#iframe3009").contents().find("body").height()+showittryitheight); this.scrollIntoView(true); editor3009.focus(); editor3009.setSize(null, "250"); $("#rendering3009").hide(); $("#rendered3009").hide(); }); var mixedMode = { name: "htmlmixed", scriptTypes: [{matches: /\/x-handlebars-template|\/x-mustache/i, mode: null}, {matches: /(text|application)\/(x-)?vb(a|script)/i, mode: "vbscript"}] }; var editor3009 = CodeMirror.fromTextArea(document.getElementById("stepcodeTextarea3009"), { lineNumbers: true, styleActiveLine: true, matchBrackets: true, mode:"text/html", theme:"eclipse", selectionPointer: true, lineWrapping: true, extraKeys: { "Alt-/": "autocomplete", "Ctrl-F": "findPersistent", "F8": function(cm) { cm.setOption("fullScreen", !cm.getOption("fullScreen")); }, "Esc": function(cm) { if (cm.getOption("fullScreen")) cm.setOption("fullScreen", false); } } }); editor3009.on("change",function(doc){ if(!binded3009){ $(window).bind('beforeunload',function(){ binded3009 = true; return "xxxx"; }); } var newCode = doc.getValue(); code3009 = newCode; $("textarea#stepcodeTextarea3009").val(newCode); if(alreadyWriteCode3009!=code3009){ lastModifedTime3009 = new Date().getTime(); $("#rendering3009").show(); $("#rendered3009").hide(); } // alert(doc.getValue()); }); $(".CodeMirror").addClass("form-control"); // var editor3009 = CodeMirror.fromTextArea(, { // lineNumbers: true, // styleActiveLine: true, // matchBrackets: true, // theme:"eclipse", // }); editor3009.on("change",function(doc){ // alert(doc.getValue()); }); $("#tryDiv3009").hide(); }); $("div.codemirrorTips span").addClass("glyphicon glyphicon-asterisk");


源代码
1. 双击选中单词 2. 三击选中整行 3. CTRL+F 查找 4. F8 全屏编辑,再次点击恢复
渲染中 渲染完成
效果


HOW2J公众号,关注后实时获知布最新的教程和优惠活动,谢谢。


关于 前端部分-BootStrap-可切换导航栏 的提问

尽量提供截图代码异常信息,有助于分析和解决问题。 也可进本站QQ群交流: 620943819
提问尽量提供完整的代码,环境描述,越是有利于问题的重现,您的问题越能更快得到解答。
对教程中代码有疑问,请提供是哪个步骤,哪一行有疑问,这样便于快速定位问题,提高问题得到解答的速度
在已经存在的几千个提问里,有相当大的比例,是因为使用了和站长不同版本的开发环境导致的,比如 jdk, eclpise, idea, mysql,tomcat 等等软件的版本不一致。
请使用和站长一样的版本,可以节约自己大量的学习时间。 站长把教学中用的软件版本整理了,都统一放在了这里, 方便大家下载: http://how2j.cn/k/helloworld/helloworld-version/1718.html

上传截图