how2j.cn


工具版本兼容问题
<i>和<em>都可以表示斜体效果

示例 1 : 斜体   
示例 2 : 同时具有粗体和斜体效果   

示例 1 :

斜体

区别:
i是italic的缩写,仅仅表示该文本是斜体的,并不暗示这段文字的重要性

em 是 Emphasized的缩写,虽然也是斜体,但是更多的是强调语义上的加重,提醒用户该文本的重要性。 常常用于引入新的术语的时候使用。
"); window.frames["iframe_show326"].document.write(decodeHtml($("textarea#stepcodeTextarea326").val())); window.frames["iframe_show326"].document.close(); $(window.frames["iframe_show326"]).load(function(){ $("#iframe_show326").height($("#iframe_show326").contents().find("body").height()+showittryitheight); }); $("#iframe_show326").height($("#iframe_show326").contents().find("body").height()+showittryitheight); setTimeout(function(){ },500); });
运行效果
<p>无斜体效果</p> <i>使用 i 标签带来的斜体效果</i> <br/> <em>使用 em 标签带来的斜体效果</em>
<p>无斜体效果</p>

<i>使用 i 标签带来的斜体效果</i>
<br/>

<em>使用 em 标签带来的斜体效果</em>

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


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

同时具有粗体和斜体效果

通过嵌套实现多种效果
嵌套即标签中有标签
"); window.frames["iframe_show327"].document.write(decodeHtml($("textarea#stepcodeTextarea327").val())); window.frames["iframe_show327"].document.close(); $(window.frames["iframe_show327"]).load(function(){ $("#iframe_show327").height($("#iframe_show327").contents().find("body").height()+showittryitheight); }); $("#iframe_show327").height($("#iframe_show327").contents().find("body").height()+showittryitheight); setTimeout(function(){ },500); });
运行效果
<p>无效果</p> <strong>粗体</strong> <br/> <i>斜体</i> <br/> <strong><i>同时有粗体和斜体</i></strong>
<p>无效果</p>
<strong>粗体</strong>
<br/>
<i>斜体</i>
<br/>
<strong><i>同时有粗体和斜体</i></strong>
"); window.frames["iframe327"].document.write(decodeHtml(code327)); window.frames["iframe327"].document.close(); //load和下面的非load必需并存,因为如果代码用到了jquery就必须使用load的方式 $(window.frames["iframe327"]).load(function(){ $("#iframe327").height($("#iframe327").contents().find("body").height()+showittryitheight); }); $("#iframe327").height($("#iframe327").contents().find("body").height()+showittryitheight); alreadyWriteCode327 = code327; $("#rendering327").hide(); $("#rendered327").show(); } var tRereshRetry2DemoPanel327 = setInterval(rereshRetry2DemoPanel327,1000); var binded327 = false; $("textarea#stepcodeTextarea327").keyup(function(){ if(!binded327){ $(window).bind('beforeunload',function(){ binded327 = true; return "xxxx"; }); } var newCode = $(this).val() code327 = newCode; /*below code is replaced by function rereshRetry2DemoPanel()*/ // if(code327!=newCode){ // window.frames["iframe327"].document.write("
"); // window.frames["iframe327"].document.write(decodeHtml($("textarea#stepcodeTextarea327").val())); // window.frames["iframe327"].document.close(); // $(window.frames["iframe327"]).load(function(){ // $("#iframe327").height($("#iframe327").contents().find("body").height()+showittryitheight); // }); // code327 = newCode; // } }); $(".tryButton327").click(function(){ $("#tryDiv327").show(); $("#stepcodeTextarea327").focus(); $("#stepcodeTextarea327").height(200); $("#iframe327").height(0); window.frames["iframe327"].document.write("
"); window.frames["iframe327"].document.write(decodeHtml($("textarea#stepcodeTextarea327").val())); window.frames["iframe327"].document.close(); //load和下面的非load必需并存,因为如果代码用到了jquery就必须使用load的方式 $(window.frames["iframe327"]).load(function(){ $("#iframe327").height($("#iframe327").contents().find("body").height()+showittryitheight); }); $("#iframe327").height($("#iframe327").contents().find("body").height()+showittryitheight); this.scrollIntoView(true); editor327.focus(); editor327.setSize(null, "250"); $("#rendering327").hide(); $("#rendered327").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 editor327 = CodeMirror.fromTextArea(document.getElementById("stepcodeTextarea327"), { 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); } } }); editor327.on("change",function(doc){ if(!binded327){ $(window).bind('beforeunload',function(){ binded327 = true; return "xxxx"; }); } var newCode = doc.getValue(); code327 = newCode; $("textarea#stepcodeTextarea327").val(newCode); if(alreadyWriteCode327!=code327){ lastModifedTime327 = new Date().getTime(); $("#rendering327").show(); $("#rendered327").hide(); } // alert(doc.getValue()); }); $(".CodeMirror").addClass("form-control"); // var editor327 = CodeMirror.fromTextArea(, { // lineNumbers: true, // styleActiveLine: true, // matchBrackets: true, // theme:"eclipse", // }); editor327.on("change",function(doc){ // alert(doc.getValue()); }); $("#tryDiv327").hide(); }); $("div.codemirrorTips span").addClass("glyphicon glyphicon-asterisk");


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


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


关于 前端部分-HTML-斜体 的提问

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

上传截图