how2j.cn


工具版本兼容问题
BootStrap 是Twitter的工程师开发的前端框架,可以非常方便的设计出好看的页面效果。

本章演示一些基本元素 使用 Bootstrap和不用的区别


步骤 1 :

使用Bootstrap和不用的区别

演示按钮 输入框 下拉框等常见的组件,在原生html和Bootstrap的效果比较
同时还演示了几种html中没有的效果
"); window.frames["iframe_show1252"].document.write(decodeHtml($("textarea#stepcodeTextarea1252").val())); window.frames["iframe_show1252"].document.close(); $(window.frames["iframe_show1252"]).load(function(){ $("#iframe_show1252").height($("#iframe_show1252").contents().find("body").height()+showittryitheight); }); $("#iframe_show1252").height($("#iframe_show1252").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> <table width="200" border="1" class="table table-bordered"> <tr> <td>HTML</td> <td>Bootstrap</td> </tr> <tr> <td><button>按钮</button></td> <td><button class="btn btn-success">按钮</button></td> </tr> <tr> <td><input type="text" value="输入框"></td> <td><input type="text" value="输入框" class="form-control"></td> </tr> <tr> <td> <select > <option>多选框</option> <option>多选框</option> <option>多选框</option> <option>多选框</option> </select> </td> <td> <select class="form-control"> <option>多选框</option> <option>多选框</option> <option>多选框</option> <option>多选框</option> </select> </td> </tr> </tr> <tr> <td >下拉菜单(传统HTML不提供)</td> <td> <div class="dropdown"> <button type="button" class="btn dropdown-toggle" id="dropdownMenu1" data-toggle="dropdown"> http://192.168.1.189 <span class="caret"></span> </button> <ul class="dropdown-menu" role="menu" aria-labelledby="dropdownMenu1"> <li> <a href="#">Java基础</a> </li> <li role="presentation"> <a href="#">Java中级</a> </li> <li role="presentation"> <a href="#">前端基础</a> </li> <li role="presentation" class="divider"></li> <li role="presentation"> <a href="#">服务端</a> </li> <li role="presentation"> <a href="#">框架</a> </li> </ul> </div> </td> </tr> <tr> <td >面板(传统HTML不提供)</td> <td> <div class="panel panel-success"> <div class="panel-heading">面板标题</div> <div class="panel-body"> 面板内容<br> 面板内容<br> 面板内容 </div> </div> </td> </tr> </table>
"); window.frames["iframe1252"].document.write(decodeHtml(code1252)); window.frames["iframe1252"].document.close(); //load和下面的非load必需并存,因为如果代码用到了jquery就必须使用load的方式 $(window.frames["iframe1252"]).load(function(){ $("#iframe1252").height($("#iframe1252").contents().find("body").height()+showittryitheight); }); $("#iframe1252").height($("#iframe1252").contents().find("body").height()+showittryitheight); alreadyWriteCode1252 = code1252; $("#rendering1252").hide(); $("#rendered1252").show(); } var tRereshRetry2DemoPanel1252 = setInterval(rereshRetry2DemoPanel1252,1000); var binded1252 = false; $("textarea#stepcodeTextarea1252").keyup(function(){ if(!binded1252){ $(window).bind('beforeunload',function(){ binded1252 = true; return "xxxx"; }); } var newCode = $(this).val() code1252 = newCode; /*below code is replaced by function rereshRetry2DemoPanel()*/ // if(code1252!=newCode){ // window.frames["iframe1252"].document.write("
"); // window.frames["iframe1252"].document.write(decodeHtml($("textarea#stepcodeTextarea1252").val())); // window.frames["iframe1252"].document.close(); // $(window.frames["iframe1252"]).load(function(){ // $("#iframe1252").height($("#iframe1252").contents().find("body").height()+showittryitheight); // }); // code1252 = newCode; // } }); $(".tryButton1252").click(function(){ $("#tryDiv1252").show(); $("#stepcodeTextarea1252").focus(); $("#stepcodeTextarea1252").height(200); $("#iframe1252").height(0); window.frames["iframe1252"].document.write("
"); window.frames["iframe1252"].document.write(decodeHtml($("textarea#stepcodeTextarea1252").val())); window.frames["iframe1252"].document.close(); //load和下面的非load必需并存,因为如果代码用到了jquery就必须使用load的方式 $(window.frames["iframe1252"]).load(function(){ $("#iframe1252").height($("#iframe1252").contents().find("body").height()+showittryitheight); }); $("#iframe1252").height($("#iframe1252").contents().find("body").height()+showittryitheight); this.scrollIntoView(true); editor1252.focus(); editor1252.setSize(null, "250"); $("#rendering1252").hide(); $("#rendered1252").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 editor1252 = CodeMirror.fromTextArea(document.getElementById("stepcodeTextarea1252"), { 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); } } }); editor1252.on("change",function(doc){ if(!binded1252){ $(window).bind('beforeunload',function(){ binded1252 = true; return "xxxx"; }); } var newCode = doc.getValue(); code1252 = newCode; $("textarea#stepcodeTextarea1252").val(newCode); if(alreadyWriteCode1252!=code1252){ lastModifedTime1252 = new Date().getTime(); $("#rendering1252").show(); $("#rendered1252").hide(); } // alert(doc.getValue()); }); $(".CodeMirror").addClass("form-control"); // var editor1252 = CodeMirror.fromTextArea(, { // lineNumbers: true, // styleActiveLine: true, // matchBrackets: true, // theme:"eclipse", // }); editor1252.on("change",function(doc){ // alert(doc.getValue()); }); $("#tryDiv1252").hide(); }); $("div.codemirrorTips span").addClass("glyphicon glyphicon-asterisk");


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


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


关于 前端部分-BootStrap-Hello BootStrap 的提问

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

上传截图