how2j.cn

相关下载
文件名 文件大小
bootstrap.rar 288k
使用站长秘制下载工具

工具版本兼容问题
使用Bootstrap 很简单,按照如下步骤进行即可。

步骤 1 : <!DOCTYPE html>   
步骤 2 : 导入js 导入css   
步骤 3 : 套用class   
步骤 4 : 本地测试   

步骤 1 :

<!DOCTYPE html>

因为bootstrap用到了html5的特性,为了正常使用,需要在最开头加上


<!DOCTYPE html>
<!DOCTYPE html>
<!DOCTYPE html>
步骤 2 :

导入js 导入css

接着导入js和css
Bootstrap需要JQuery才能正常工作,所以需要导入jquery.min.js
接着是 Bootstrap的css,里面定义了各种样式
最后是 Bootstrap的js,用于产生交互效果,比如关闭警告框
注:顺序不要搞错了,否则有一些效果会出不来。
首先是JQuery
然后是Bootstrap css
最后是Bootstrap js

<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>
<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>
步骤 3 :

套用class

接着就是出现BootStrap的效果,使用是非常简单的,只需要套用 bootstrap css中定义的class即可。
如按钮,增加class btn btn-success 就能有bootstrap的效果了
简单的吓死人
"); window.frames["iframe_show1256"].document.write(decodeHtml($("textarea#stepcodeTextarea1256").val())); window.frames["iframe_show1256"].document.close(); $(window.frames["iframe_show1256"]).load(function(){ $("#iframe_show1256").height($("#iframe_show1256").contents().find("body").height()+showittryitheight); }); $("#iframe_show1256").height($("#iframe_show1256").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> <button class="btn btn-success">按钮</button>
<!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>

<button class="btn btn-success">按钮</button>

"); window.frames["iframe1256"].document.write(decodeHtml(code1256)); window.frames["iframe1256"].document.close(); //load和下面的非load必需并存,因为如果代码用到了jquery就必须使用load的方式 $(window.frames["iframe1256"]).load(function(){ $("#iframe1256").height($("#iframe1256").contents().find("body").height()+showittryitheight); }); $("#iframe1256").height($("#iframe1256").contents().find("body").height()+showittryitheight); alreadyWriteCode1256 = code1256; $("#rendering1256").hide(); $("#rendered1256").show(); } var tRereshRetry2DemoPanel1256 = setInterval(rereshRetry2DemoPanel1256,1000); var binded1256 = false; $("textarea#stepcodeTextarea1256").keyup(function(){ if(!binded1256){ $(window).bind('beforeunload',function(){ binded1256 = true; return "xxxx"; }); } var newCode = $(this).val() code1256 = newCode; /*below code is replaced by function rereshRetry2DemoPanel()*/ // if(code1256!=newCode){ // window.frames["iframe1256"].document.write("
"); // window.frames["iframe1256"].document.write(decodeHtml($("textarea#stepcodeTextarea1256").val())); // window.frames["iframe1256"].document.close(); // $(window.frames["iframe1256"]).load(function(){ // $("#iframe1256").height($("#iframe1256").contents().find("body").height()+showittryitheight); // }); // code1256 = newCode; // } }); $(".tryButton1256").click(function(){ $("#tryDiv1256").show(); $("#stepcodeTextarea1256").focus(); $("#stepcodeTextarea1256").height(200); $("#iframe1256").height(0); window.frames["iframe1256"].document.write("
"); window.frames["iframe1256"].document.write(decodeHtml($("textarea#stepcodeTextarea1256").val())); window.frames["iframe1256"].document.close(); //load和下面的非load必需并存,因为如果代码用到了jquery就必须使用load的方式 $(window.frames["iframe1256"]).load(function(){ $("#iframe1256").height($("#iframe1256").contents().find("body").height()+showittryitheight); }); $("#iframe1256").height($("#iframe1256").contents().find("body").height()+showittryitheight); this.scrollIntoView(true); editor1256.focus(); editor1256.setSize(null, "250"); $("#rendering1256").hide(); $("#rendered1256").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 editor1256 = CodeMirror.fromTextArea(document.getElementById("stepcodeTextarea1256"), { 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); } } }); editor1256.on("change",function(doc){ if(!binded1256){ $(window).bind('beforeunload',function(){ binded1256 = true; return "xxxx"; }); } var newCode = doc.getValue(); code1256 = newCode; $("textarea#stepcodeTextarea1256").val(newCode); if(alreadyWriteCode1256!=code1256){ lastModifedTime1256 = new Date().getTime(); $("#rendering1256").show(); $("#rendered1256").hide(); } // alert(doc.getValue()); }); $(".CodeMirror").addClass("form-control"); // var editor1256 = CodeMirror.fromTextArea(, { // lineNumbers: true, // styleActiveLine: true, // matchBrackets: true, // theme:"eclipse", // }); editor1256.on("change",function(doc){ // alert(doc.getValue()); }); $("#tryDiv1256").hide(); }); $("div.codemirrorTips span").addClass("glyphicon glyphicon-asterisk");


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

本地测试

首先在右侧下载bootstrap.rar
解压后和html放在同一个目录下
js和css的引用也如图所示
本地测试
<!DOCTYPE html> <script src="js/jquery/2.0.0/jquery.min.js"></script> <link href="css/bootstrap/3.3.6/bootstrap.min.css" rel="stylesheet"> <script src="js/bootstrap/3.3.6/bootstrap.min.js"></script> <button class="btn btn-success">按钮</button>
<!DOCTYPE html>
<script src="js/jquery/2.0.0/jquery.min.js"></script>
<link href="css/bootstrap/3.3.6/bootstrap.min.css" rel="stylesheet">
<script src="js/bootstrap/3.3.6/bootstrap.min.js"></script>
 
<button class="btn btn-success">按钮</button>


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


关于 前端部分-BootStrap-如何使用 的提问

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

上传截图