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>

<style>
  body{
    padding-top:70px;
  }
</style>
<nav class="navbar navbar-default navbar-fixed-top">
  <button class="btn btn-info">菜单1</button>
  <button class="btn btn-success">菜单2</button>
  <button class="btn btn-danger">菜单3</button>
</nav>

<div style="white-space:pre">
  很多内容 ,下拉才看得见,下拉时,置顶菜单不消失
  很多内容 ,下拉才看得见,下拉时,置顶菜单不消失
  很多内容 ,下拉才看得见,下拉时,置顶菜单不消失
  很多内容 ,下拉才看得见,下拉时,置顶菜单不消失
</div>
贴在顶部(不会消失)
示例代码
<!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>

<style>
  body{
    padding-bottom:70px;
  }
</style>
<nav class="navbar navbar-default navbar-static-top">
  <button class="btn btn-info">菜单1</button>
  <button class="btn btn-success">菜单2</button>
  <button class="btn btn-danger">菜单3</button>
</nav>

<div style="white-space:pre">
  很多内容 ,下拉才看得见,下拉时,置顶菜单会消失
  很多内容 ,下拉才看得见,下拉时,置顶菜单会消失
  很多内容 ,下拉才看得见,下拉时,置顶菜单会消失
  很多内容 ,下拉才看得见,下拉时,置顶菜单会消失
  很多内容 ,下拉才看得见,下拉时,置顶菜单会消失
  很多内容 ,下拉才看得见,下拉时,置顶菜单会消失
  很多内容 ,下拉才看得见,下拉时,置顶菜单会消失
</div>
贴在顶部(会消失)
示例代码
<!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>

<style>
  body{
    padding-bottom:70px;
  }
</style>

<div style="white-space:pre">
 拉动内容时,置底版权信息位置不变
 拉动内容时,置底版权信息位置不变
 拉动内容时,置底版权信息位置不变
 拉动内容时,置底版权信息位置不变

</div>

<nav class="navbar navbar-default navbar-fixed-bottom">
<div style="text-align:center">
 版权所有
</div>
</nav>
贴在底部 (不会消失)
示例代码
步骤 1 : 贴在顶部(不会消失)   
步骤 2 : 贴在顶部(会消失)   
步骤 3 : 贴在底部 (不会消失)   

步骤 1 :

贴在顶部(不会消失)

贴在顶部,如果内容比较多,需要下拉滚动才可以看到的时候,会继续保持帖在顶部的状态。
使用的时候需要加上样式:

body{
padding-top:70px;
}
"); window.frames["iframe_show3071"].document.write(decodeHtml($("textarea#stepcodeTextarea3071").val())); window.frames["iframe_show3071"].document.close(); $(window.frames["iframe_show3071"]).load(function(){ $("#iframe_show3071").height($("#iframe_show3071").contents().find("body").height()+showittryitheight); }); $("#iframe_show3071").height($("#iframe_show3071").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> <style> body{ padding-top:70px; } </style> <nav class="navbar navbar-default navbar-fixed-top"> <button class="btn btn-info">菜单1</button> <button class="btn btn-success">菜单2</button> <button class="btn btn-danger">菜单3</button> </nav> <div style="white-space:pre"> 很多内容 ,下拉才看得见,下拉时,置顶菜单不消失 很多内容 ,下拉才看得见,下拉时,置顶菜单不消失 很多内容 ,下拉才看得见,下拉时,置顶菜单不消失 很多内容 ,下拉才看得见,下拉时,置顶菜单不消失 </div>
"); window.frames["iframe3071"].document.write(decodeHtml(code3071)); window.frames["iframe3071"].document.close(); //load和下面的非load必需并存,因为如果代码用到了jquery就必须使用load的方式 $(window.frames["iframe3071"]).load(function(){ $("#iframe3071").height($("#iframe3071").contents().find("body").height()+showittryitheight); }); $("#iframe3071").height($("#iframe3071").contents().find("body").height()+showittryitheight); alreadyWriteCode3071 = code3071; $("#rendering3071").hide(); $("#rendered3071").show(); } var tRereshRetry2DemoPanel3071 = setInterval(rereshRetry2DemoPanel3071,1000); var binded3071 = false; $("textarea#stepcodeTextarea3071").keyup(function(){ if(!binded3071){ $(window).bind('beforeunload',function(){ binded3071 = true; return "xxxx"; }); } var newCode = $(this).val() code3071 = newCode; /*below code is replaced by function rereshRetry2DemoPanel()*/ // if(code3071!=newCode){ // window.frames["iframe3071"].document.write("
"); // window.frames["iframe3071"].document.write(decodeHtml($("textarea#stepcodeTextarea3071").val())); // window.frames["iframe3071"].document.close(); // $(window.frames["iframe3071"]).load(function(){ // $("#iframe3071").height($("#iframe3071").contents().find("body").height()+showittryitheight); // }); // code3071 = newCode; // } }); $(".tryButton3071").click(function(){ $("#tryDiv3071").show(); $("#stepcodeTextarea3071").focus(); $("#stepcodeTextarea3071").height(200); $("#iframe3071").height(0); window.frames["iframe3071"].document.write("
"); window.frames["iframe3071"].document.write(decodeHtml($("textarea#stepcodeTextarea3071").val())); window.frames["iframe3071"].document.close(); //load和下面的非load必需并存,因为如果代码用到了jquery就必须使用load的方式 $(window.frames["iframe3071"]).load(function(){ $("#iframe3071").height($("#iframe3071").contents().find("body").height()+showittryitheight); }); $("#iframe3071").height($("#iframe3071").contents().find("body").height()+showittryitheight); this.scrollIntoView(true); editor3071.focus(); editor3071.setSize(null, "250"); $("#rendering3071").hide(); $("#rendered3071").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 editor3071 = CodeMirror.fromTextArea(document.getElementById("stepcodeTextarea3071"), { 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); } } }); editor3071.on("change",function(doc){ if(!binded3071){ $(window).bind('beforeunload',function(){ binded3071 = true; return "xxxx"; }); } var newCode = doc.getValue(); code3071 = newCode; $("textarea#stepcodeTextarea3071").val(newCode); if(alreadyWriteCode3071!=code3071){ lastModifedTime3071 = new Date().getTime(); $("#rendering3071").show(); $("#rendered3071").hide(); } // alert(doc.getValue()); }); $(".CodeMirror").addClass("form-control"); // var editor3071 = CodeMirror.fromTextArea(, { // lineNumbers: true, // styleActiveLine: true, // matchBrackets: true, // theme:"eclipse", // }); editor3071.on("change",function(doc){ // alert(doc.getValue()); }); $("#tryDiv3071").hide(); }); $("div.codemirrorTips span").addClass("glyphicon glyphicon-asterisk");


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

贴在顶部(会消失)

贴在顶部(会消失)
不需要样式

body{
/* padding-top:70px;*/
}


在本例中却加了一个 padding-bottom:70px;,为的是出现下拉条,与本例演示目的没有直接关系。
"); window.frames["iframe_show3073"].document.write(decodeHtml($("textarea#stepcodeTextarea3073").val())); window.frames["iframe_show3073"].document.close(); $(window.frames["iframe_show3073"]).load(function(){ $("#iframe_show3073").height($("#iframe_show3073").contents().find("body").height()+showittryitheight); }); $("#iframe_show3073").height($("#iframe_show3073").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> <style> body{ padding-bottom:70px; } </style> <nav class="navbar navbar-default navbar-static-top"> <button class="btn btn-info">菜单1</button> <button class="btn btn-success">菜单2</button> <button class="btn btn-danger">菜单3</button> </nav> <div style="white-space:pre"> 很多内容 ,下拉才看得见,下拉时,置顶菜单会消失 很多内容 ,下拉才看得见,下拉时,置顶菜单会消失 很多内容 ,下拉才看得见,下拉时,置顶菜单会消失 很多内容 ,下拉才看得见,下拉时,置顶菜单会消失 很多内容 ,下拉才看得见,下拉时,置顶菜单会消失 很多内容 ,下拉才看得见,下拉时,置顶菜单会消失 很多内容 ,下拉才看得见,下拉时,置顶菜单会消失 </div>
"); window.frames["iframe3073"].document.write(decodeHtml(code3073)); window.frames["iframe3073"].document.close(); //load和下面的非load必需并存,因为如果代码用到了jquery就必须使用load的方式 $(window.frames["iframe3073"]).load(function(){ $("#iframe3073").height($("#iframe3073").contents().find("body").height()+showittryitheight); }); $("#iframe3073").height($("#iframe3073").contents().find("body").height()+showittryitheight); alreadyWriteCode3073 = code3073; $("#rendering3073").hide(); $("#rendered3073").show(); } var tRereshRetry2DemoPanel3073 = setInterval(rereshRetry2DemoPanel3073,1000); var binded3073 = false; $("textarea#stepcodeTextarea3073").keyup(function(){ if(!binded3073){ $(window).bind('beforeunload',function(){ binded3073 = true; return "xxxx"; }); } var newCode = $(this).val() code3073 = newCode; /*below code is replaced by function rereshRetry2DemoPanel()*/ // if(code3073!=newCode){ // window.frames["iframe3073"].document.write("
"); // window.frames["iframe3073"].document.write(decodeHtml($("textarea#stepcodeTextarea3073").val())); // window.frames["iframe3073"].document.close(); // $(window.frames["iframe3073"]).load(function(){ // $("#iframe3073").height($("#iframe3073").contents().find("body").height()+showittryitheight); // }); // code3073 = newCode; // } }); $(".tryButton3073").click(function(){ $("#tryDiv3073").show(); $("#stepcodeTextarea3073").focus(); $("#stepcodeTextarea3073").height(200); $("#iframe3073").height(0); window.frames["iframe3073"].document.write("
"); window.frames["iframe3073"].document.write(decodeHtml($("textarea#stepcodeTextarea3073").val())); window.frames["iframe3073"].document.close(); //load和下面的非load必需并存,因为如果代码用到了jquery就必须使用load的方式 $(window.frames["iframe3073"]).load(function(){ $("#iframe3073").height($("#iframe3073").contents().find("body").height()+showittryitheight); }); $("#iframe3073").height($("#iframe3073").contents().find("body").height()+showittryitheight); this.scrollIntoView(true); editor3073.focus(); editor3073.setSize(null, "250"); $("#rendering3073").hide(); $("#rendered3073").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 editor3073 = CodeMirror.fromTextArea(document.getElementById("stepcodeTextarea3073"), { 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); } } }); editor3073.on("change",function(doc){ if(!binded3073){ $(window).bind('beforeunload',function(){ binded3073 = true; return "xxxx"; }); } var newCode = doc.getValue(); code3073 = newCode; $("textarea#stepcodeTextarea3073").val(newCode); if(alreadyWriteCode3073!=code3073){ lastModifedTime3073 = new Date().getTime(); $("#rendering3073").show(); $("#rendered3073").hide(); } // alert(doc.getValue()); }); $(".CodeMirror").addClass("form-control"); // var editor3073 = CodeMirror.fromTextArea(, { // lineNumbers: true, // styleActiveLine: true, // matchBrackets: true, // theme:"eclipse", // }); editor3073.on("change",function(doc){ // alert(doc.getValue()); }); $("#tryDiv3073").hide(); }); $("div.codemirrorTips span").addClass("glyphicon glyphicon-asterisk");


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

贴在底部 (不会消失)

贴在底部
需要加上如下样式:

body{
padding-bottom:70px;
}
"); window.frames["iframe_show3072"].document.write(decodeHtml($("textarea#stepcodeTextarea3072").val())); window.frames["iframe_show3072"].document.close(); $(window.frames["iframe_show3072"]).load(function(){ $("#iframe_show3072").height($("#iframe_show3072").contents().find("body").height()+showittryitheight); }); $("#iframe_show3072").height($("#iframe_show3072").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> <style> body{ padding-bottom:70px; } </style> <div style="white-space:pre"> 拉动内容时,置底版权信息位置不变 拉动内容时,置底版权信息位置不变 拉动内容时,置底版权信息位置不变 拉动内容时,置底版权信息位置不变 </div> <nav class="navbar navbar-default navbar-fixed-bottom"> <div style="text-align:center"> 版权所有 </div> </nav>
"); window.frames["iframe3072"].document.write(decodeHtml(code3072)); window.frames["iframe3072"].document.close(); //load和下面的非load必需并存,因为如果代码用到了jquery就必须使用load的方式 $(window.frames["iframe3072"]).load(function(){ $("#iframe3072").height($("#iframe3072").contents().find("body").height()+showittryitheight); }); $("#iframe3072").height($("#iframe3072").contents().find("body").height()+showittryitheight); alreadyWriteCode3072 = code3072; $("#rendering3072").hide(); $("#rendered3072").show(); } var tRereshRetry2DemoPanel3072 = setInterval(rereshRetry2DemoPanel3072,1000); var binded3072 = false; $("textarea#stepcodeTextarea3072").keyup(function(){ if(!binded3072){ $(window).bind('beforeunload',function(){ binded3072 = true; return "xxxx"; }); } var newCode = $(this).val() code3072 = newCode; /*below code is replaced by function rereshRetry2DemoPanel()*/ // if(code3072!=newCode){ // window.frames["iframe3072"].document.write("
"); // window.frames["iframe3072"].document.write(decodeHtml($("textarea#stepcodeTextarea3072").val())); // window.frames["iframe3072"].document.close(); // $(window.frames["iframe3072"]).load(function(){ // $("#iframe3072").height($("#iframe3072").contents().find("body").height()+showittryitheight); // }); // code3072 = newCode; // } }); $(".tryButton3072").click(function(){ $("#tryDiv3072").show(); $("#stepcodeTextarea3072").focus(); $("#stepcodeTextarea3072").height(200); $("#iframe3072").height(0); window.frames["iframe3072"].document.write("
"); window.frames["iframe3072"].document.write(decodeHtml($("textarea#stepcodeTextarea3072").val())); window.frames["iframe3072"].document.close(); //load和下面的非load必需并存,因为如果代码用到了jquery就必须使用load的方式 $(window.frames["iframe3072"]).load(function(){ $("#iframe3072").height($("#iframe3072").contents().find("body").height()+showittryitheight); }); $("#iframe3072").height($("#iframe3072").contents().find("body").height()+showittryitheight); this.scrollIntoView(true); editor3072.focus(); editor3072.setSize(null, "250"); $("#rendering3072").hide(); $("#rendered3072").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 editor3072 = CodeMirror.fromTextArea(document.getElementById("stepcodeTextarea3072"), { 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); } } }); editor3072.on("change",function(doc){ if(!binded3072){ $(window).bind('beforeunload',function(){ binded3072 = true; return "xxxx"; }); } var newCode = doc.getValue(); code3072 = newCode; $("textarea#stepcodeTextarea3072").val(newCode); if(alreadyWriteCode3072!=code3072){ lastModifedTime3072 = new Date().getTime(); $("#rendering3072").show(); $("#rendered3072").hide(); } // alert(doc.getValue()); }); $(".CodeMirror").addClass("form-control"); // var editor3072 = CodeMirror.fromTextArea(, { // lineNumbers: true, // styleActiveLine: true, // matchBrackets: true, // theme:"eclipse", // }); editor3072.on("change",function(doc){ // alert(doc.getValue()); }); $("#tryDiv3072").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

上传截图