how2j.cn


工具版本兼容问题
表格相关样式

关键字 简介 示例代码
table-layout:automatic|fixed
表格布局
示例代码
border-collapse:separate|collapse
表格边框
示例代码
示例 1 : 表格布局   
示例 2 : 表格边框   

示例 1 :

表格布局

属性:table-layout
automatic; 单元格的大小由td的内容宽度决定
fixed; 单元格的大小由td上设置的宽度决定
:只对连续的英文字母起作用,如果使用中文就看不到效果
"); window.frames["iframe_show472"].document.write(decodeHtml($("textarea#stepcodeTextarea472").val())); window.frames["iframe_show472"].document.close(); $(window.frames["iframe_show472"]).load(function(){ $("#iframe_show472").height($("#iframe_show472").contents().find("body").height()+showittryitheight); }); $("#iframe_show472").height($("#iframe_show472").contents().find("body").height()+showittryitheight); setTimeout(function(){ },500); });
运行效果
<style> table.t1{ table-layout:automatic; } table.t2{ table-layout:fixed; } </style> <table class="t1" border="1" width="100%"> <tr> <td width="10%">abcdefghijklmnopqrstuvwxyz</td> <td width="90%">abc</td> </tr> </table> <table class="t2" border="1" width="100%"> <tr> <td width="50px">abcdefghijklmnopqrstuvwxyz</td> <td >abc</td> </tr> </table>
"); window.frames["iframe472"].document.write(decodeHtml(code472)); window.frames["iframe472"].document.close(); //load和下面的非load必需并存,因为如果代码用到了jquery就必须使用load的方式 $(window.frames["iframe472"]).load(function(){ $("#iframe472").height($("#iframe472").contents().find("body").height()+showittryitheight); }); $("#iframe472").height($("#iframe472").contents().find("body").height()+showittryitheight); alreadyWriteCode472 = code472; $("#rendering472").hide(); $("#rendered472").show(); } var tRereshRetry2DemoPanel472 = setInterval(rereshRetry2DemoPanel472,1000); var binded472 = false; $("textarea#stepcodeTextarea472").keyup(function(){ if(!binded472){ $(window).bind('beforeunload',function(){ binded472 = true; return "xxxx"; }); } var newCode = $(this).val() code472 = newCode; /*below code is replaced by function rereshRetry2DemoPanel()*/ // if(code472!=newCode){ // window.frames["iframe472"].document.write("
"); // window.frames["iframe472"].document.write(decodeHtml($("textarea#stepcodeTextarea472").val())); // window.frames["iframe472"].document.close(); // $(window.frames["iframe472"]).load(function(){ // $("#iframe472").height($("#iframe472").contents().find("body").height()+showittryitheight); // }); // code472 = newCode; // } }); $(".tryButton472").click(function(){ $("#tryDiv472").show(); $("#stepcodeTextarea472").focus(); $("#stepcodeTextarea472").height(200); $("#iframe472").height(0); window.frames["iframe472"].document.write("
"); window.frames["iframe472"].document.write(decodeHtml($("textarea#stepcodeTextarea472").val())); window.frames["iframe472"].document.close(); //load和下面的非load必需并存,因为如果代码用到了jquery就必须使用load的方式 $(window.frames["iframe472"]).load(function(){ $("#iframe472").height($("#iframe472").contents().find("body").height()+showittryitheight); }); $("#iframe472").height($("#iframe472").contents().find("body").height()+showittryitheight); this.scrollIntoView(true); editor472.focus(); editor472.setSize(null, "250"); $("#rendering472").hide(); $("#rendered472").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 editor472 = CodeMirror.fromTextArea(document.getElementById("stepcodeTextarea472"), { 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); } } }); editor472.on("change",function(doc){ if(!binded472){ $(window).bind('beforeunload',function(){ binded472 = true; return "xxxx"; }); } var newCode = doc.getValue(); code472 = newCode; $("textarea#stepcodeTextarea472").val(newCode); if(alreadyWriteCode472!=code472){ lastModifedTime472 = new Date().getTime(); $("#rendering472").show(); $("#rendered472").hide(); } // alert(doc.getValue()); }); $(".CodeMirror").addClass("form-control"); // var editor472 = CodeMirror.fromTextArea(, { // lineNumbers: true, // styleActiveLine: true, // matchBrackets: true, // theme:"eclipse", // }); editor472.on("change",function(doc){ // alert(doc.getValue()); }); $("#tryDiv472").hide(); }); $("div.codemirrorTips span").addClass("glyphicon glyphicon-asterisk");


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

表格边框

属性:border-collapse
值:
separate:边框分隔
collapse:边框合并
"); window.frames["iframe_show473"].document.write(decodeHtml($("textarea#stepcodeTextarea473").val())); window.frames["iframe_show473"].document.close(); $(window.frames["iframe_show473"]).load(function(){ $("#iframe_show473").height($("#iframe_show473").contents().find("body").height()+showittryitheight); }); $("#iframe_show473").height($("#iframe_show473").contents().find("body").height()+showittryitheight); setTimeout(function(){ },500); });
运行效果
<style> table.t1{ border-collapse:separate; } table.t2{ border-collapse:collapse; } </style> <table class="t1" border="1" width="200px"> <tr> <td width="50%">边框分离</td> <td width="50%">边框分离</td> </tr> </table> <br/> <br/> <table class="t2" border="1" width="200px"> <tr> <td width="50%">边框合并</td> <td width="50%">边框合并</td> </tr> </table>
"); window.frames["iframe473"].document.write(decodeHtml(code473)); window.frames["iframe473"].document.close(); //load和下面的非load必需并存,因为如果代码用到了jquery就必须使用load的方式 $(window.frames["iframe473"]).load(function(){ $("#iframe473").height($("#iframe473").contents().find("body").height()+showittryitheight); }); $("#iframe473").height($("#iframe473").contents().find("body").height()+showittryitheight); alreadyWriteCode473 = code473; $("#rendering473").hide(); $("#rendered473").show(); } var tRereshRetry2DemoPanel473 = setInterval(rereshRetry2DemoPanel473,1000); var binded473 = false; $("textarea#stepcodeTextarea473").keyup(function(){ if(!binded473){ $(window).bind('beforeunload',function(){ binded473 = true; return "xxxx"; }); } var newCode = $(this).val() code473 = newCode; /*below code is replaced by function rereshRetry2DemoPanel()*/ // if(code473!=newCode){ // window.frames["iframe473"].document.write("
"); // window.frames["iframe473"].document.write(decodeHtml($("textarea#stepcodeTextarea473").val())); // window.frames["iframe473"].document.close(); // $(window.frames["iframe473"]).load(function(){ // $("#iframe473").height($("#iframe473").contents().find("body").height()+showittryitheight); // }); // code473 = newCode; // } }); $(".tryButton473").click(function(){ $("#tryDiv473").show(); $("#stepcodeTextarea473").focus(); $("#stepcodeTextarea473").height(200); $("#iframe473").height(0); window.frames["iframe473"].document.write("
"); window.frames["iframe473"].document.write(decodeHtml($("textarea#stepcodeTextarea473").val())); window.frames["iframe473"].document.close(); //load和下面的非load必需并存,因为如果代码用到了jquery就必须使用load的方式 $(window.frames["iframe473"]).load(function(){ $("#iframe473").height($("#iframe473").contents().find("body").height()+showittryitheight); }); $("#iframe473").height($("#iframe473").contents().find("body").height()+showittryitheight); this.scrollIntoView(true); editor473.focus(); editor473.setSize(null, "250"); $("#rendering473").hide(); $("#rendered473").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 editor473 = CodeMirror.fromTextArea(document.getElementById("stepcodeTextarea473"), { 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); } } }); editor473.on("change",function(doc){ if(!binded473){ $(window).bind('beforeunload',function(){ binded473 = true; return "xxxx"; }); } var newCode = doc.getValue(); code473 = newCode; $("textarea#stepcodeTextarea473").val(newCode); if(alreadyWriteCode473!=code473){ lastModifedTime473 = new Date().getTime(); $("#rendering473").show(); $("#rendered473").hide(); } // alert(doc.getValue()); }); $(".CodeMirror").addClass("form-control"); // var editor473 = CodeMirror.fromTextArea(, { // lineNumbers: true, // styleActiveLine: true, // matchBrackets: true, // theme:"eclipse", // }); editor473.on("change",function(doc){ // alert(doc.getValue()); }); $("#tryDiv473").hide(); }); $("div.codemirrorTips span").addClass("glyphicon glyphicon-asterisk");


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


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


关于 前端部分-CSS-表格 的提问

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

上传截图