CSS布局 0x1 盒模型和box-sizing

本文深入讲解了CSS盒模型的概念,包括边距、边框、填充和内容如何共同构成元素的盒子。通过具体实例展示了传统盒模型与box-sizing:border-box属性的区别,帮助读者理解并掌握盒模型在网页布局设计中的应用。

盒模型 

    所有HTML元素可以看作盒子,在CSS中,"box model"这一术语是用来设计和布局时使用。CSS盒模型本质上是一个盒子,封装周围的HTML元素,它包括:边距,边框,填充,和实际内容。盒模型允许我们在其它元素和周围元素边框之间的空间放置元素。

CSS box-model

 

<!DOCTYPE html>
<html>
    <head>
        <meta charset="utf-8">
        <title>margin</title>
        <style>
            .simple {
                width: 500px;
                margin: 20px auto;
                background-color: aqua
            }

            .fancy {
                width: 500px;
                margin: 20px auto;
                padding: 50px;
                border-width: 10px;
                background-color: blueviolet
            }
        </style>
    </head>
    <body>
        <div class="simple">simple</div>
        <div class="fancy">fancy</div>
    </body>
</html>

box-sizing

      人们慢慢的意识到传统的盒子模型不直接,所以他们新增了一个叫做 box-sizing 的CSS属性。当你设置一个元素为 box-sizing: border-box; 时,此元素的内边距和边框不再会增加它的宽度。这里有一个与前一页相同的例子,唯一的区别是两个元素都设置了 box-sizing: border-box; :

<!DOCTYPE html>
<html>
    <head>
        <meta charset="utf-8">
        <title>margin</title>
        <style>
            .simple {
                width: 500px;
                margin: 20px auto;
                background-color: aqua;
                -webkit-box-sizing: border-box;
                -moz-box-sizing: border-box;
                     box-sizing: border-box;
            }

            .fancy {
                width: 500px;
                margin: 20px auto;
                padding: 50px;
                border:solid blueviolet 10px;
                -webkit-box-sizing: border-box;
                -moz-box-sizing: border-box;
                     box-sizing: border-box;
            }
        </style>
    </head>
    <body>
        <div class="simple">simple</div>
        <div class="fancy">fancy</div>
    </body>
</html>

 

 

<style> #chatContainer{ width: 700px; margin: 20px auto; border: 1px solid #ccc; display: flex; flex-direction: column; background: #f9f9f9; } #chatBox { flex: 1; height: 800px; overflow-y: auto; padding: 10px; display: flex; flex-direction: column-reverse; } .msg{ max-width: 75%; margin: 8px; padding: 6px 10px; border-radius: 10px; position: relative; /* word-break: break-word; */ } .msg-info{ font-size: 11px; color: gray; margin-bottom: 2px; } .msg.inbox{ background: #f6f2f2; text-align: left; margin-right: auto; align-self: flex-start; } .msg.outbox{ background: #f6dcfc; text-align: left; margin-left: auto; /* color: white; */ align-self: flex-end; } .meta{ font-size: 14px; color : #666; margin-bottom: 4px; } #loadTip{ text-align: center; color: gray; font-size: 12px; } #editor{ border-top: 1px solid #ccc; padding: 8px; display: flex; flex-direction: column; background: #fff; } #inputContent{ width: 100%; height: 60px; resize: none; padding: 6px; box-sizing: border-box; margin-bottom: 6px; font-size: 14px; } #editorButtons{ display: flex; justify-content: flex-end; gap: 8px; } button{ padding: 6px 12px; border: none; border-radius: 5px; cursor: pointer; /* transition: background-color 0.2s ease; */ } .btn:hover{ background-color: #34a8b5; } #save{ background-color: #4acbd6; color: #f7f4f4; } #send{ background-color: #4acbd6; color: #f7f4f4; } </style> <script type="text/javascript"> (function() { var indexGlobal; var msgPageListGlobal; var smsMsgPageList; var webUIData; if ($.mainParam) { optPageGlobal = $.mainParam[0]; indexGlobal = $.mainParam[1]; msgPageListGlobal = $.mainParam[2]; } else { $.loadMain("lteSmsAllMsg.htm", null); } var lenSingleMsgArray = new Array(new Array(160, 146, 153, 153, 153), new Array(70, 64, 67, 67, 67)); var lenMsgArray = new Array(765, 335); var lenSingleMsgArrayIndex = 0; var lenSingleAddInGSM7Ext = new Array(0, 0, 0, 0, 0); var TotalLen = 0; function doEscapeCharEncode(string) { var showStr = ""; for (var i = 0; i < string.length; i++) { if (string.charAt(i) == '\n') { showStr += '\x12'; } else if (string.charAt(i) == '\r') { showStr += '\x11'; } else { showStr += string[i]; } } return showStr; } function doEscapeChar(string) { var showStr = ""; for (var i = 0; i < string.length; i++) { if (string.charCodeAt(i) == 18) { showStr += "\n"; } else if (string.charCodeAt(i) == 17) { showStr += "\r"; } else { showStr += string[i]; } } return showStr; } function outputMsgLen() { var i = 0; var lenTotalNow = $("#inputContent").val().length; var lenExceed = 0; var lenTotalAddTemp = 0; var curCharSpecial = 0; var flag; var curMsgIndex = 0; var curMsgIndexLenLeft = 0; var curMsgLenUpLimit4 = 0; var curMsgLenUpLimit3 = 0; var curMsgLenUpLimit2 = 0; var GSM_7BIT_NUM = 128; lenSingleAddInGSM7Ext[0] = 0; lenSingleAddInGSM7Ext[1] = 0; lenSingleAddInGSM7Ext[2] = 0; lenSingleAddInGSM7Ext[3] = 0; lenSingleAddInGSM7Ext[4] = 0; $("#inputLen").css("color", "#000000"); lenSingleMsgArrayIndex = 0; for (var i = 0; i < lenTotalNow; i++) { flag = 0; curCharSpecial = 0; if ( $("#inputContent").val().charCodeAt(i) == 94 || $("#inputContent").val().charCodeAt(i) == 123 || $("#inputContent").val().charCodeAt(i) == 125 || $("#inputContent").val().charCodeAt(i) == 92 || $("#inputContent").val().charCodeAt(i) == 91 || $("#inputContent").val().charCodeAt(i) == 126 || $("#inputContent").val().charCodeAt(i) == 93 || $("#inputContent").val().charCodeAt(i) == 124 || $("#inputContent").val().charCodeAt(i) == 8364 ) { flag = 1; } else { var arrayGSM_7DefaultTable = [ 0x0040, 0x00A3, 0x0024, 0x00A5, 0x00E8, 0x00E9, 0x00F9, 0x00EC, 0x00F2, 0x00C7, 0x000A, 0x00D8, 0x00F8, 0x000D, 0x00C5, 0x00E5, 0x0394, 0x005F, 0x03A6, 0x0393, 0x039B, 0x03A9, 0x03A0, 0x03A8, 0x03A3, 0x0398, 0x039E, 0x001B, 0x00C6, 0x00E6, 0x00DF, 0x00C9, 0x0020, 0x0021, 0x0022, 0x0023, 0x00A4, 0x0025, 0x0026, 0x0027, 0x0028, 0x0029, 0x002A, 0x002B, 0x002C, 0x002D, 0x002E, 0x002F, 0x0030, 0x0031, 0x0032, 0x0033, 0x0034, 0x0035, 0x0036, 0x0037, 0x0038, 0x0039, 0x003A, 0x003B, 0x003C, 0x003D, 0x003E, 0x003F, 0x00A1, 0x0041, 0x0042, 0x0043, 0x0044, 0x0045, 0x0046, 0x0047, 0x0048, 0x0049, 0x004A, 0x004B, 0x004C, 0x004D, 0x004E, 0x004F, 0x0050, 0x0051, 0x0052, 0x0053, 0x0054, 0x0055, 0x0056, 0x0057, 0x0058, 0x0059, 0x005A, 0x00C4, 0x00D6, 0x00D1, 0x00DC, 0x00A7, 0x00BF, 0x0061, 0x0062, 0x0063, 0x0064, 0x0065, 0x0066, 0x0067, 0x0068, 0x0069, 0x006A, 0x006B, 0x006C, 0x006D, 0x006E, 0x006F, 0x0070, 0x0071, 0x0072, 0x0073, 0x0074, 0x0075, 0x0076, 0x0077, 0x0078, 0x0079, 0x007A, 0x00E4, 0x00F6, 0x00F1, 0x00FC, 0x00E0 ]; for(var j = 0; j < GSM_7BIT_NUM; j++) { if ($("#inputContent").val().charCodeAt(i) == arrayGSM_7DefaultTable[j]) { flag = 1; break; } } } if (flag == 0) { lenSingleMsgArrayIndex = 1; } lenTotalAddTemp = lenSingleAddInGSM7Ext[0] + lenSingleAddInGSM7Ext[1] + lenSingleAddInGSM7Ext[2] + lenSingleAddInGSM7Ext[3] + lenSingleAddInGSM7Ext[4]; curMsgLenUpLimit4 = lenSingleMsgArray[lenSingleMsgArrayIndex][0] + lenSingleMsgArray[lenSingleMsgArrayIndex][1] + lenSingleMsgArray[lenSingleMsgArrayIndex][2] + lenSingleMsgArray[lenSingleMsgArrayIndex][3]; curMsgLenUpLimit3 = lenSingleMsgArray[lenSingleMsgArrayIndex][0] + lenSingleMsgArray[lenSingleMsgArrayIndex][1] + lenSingleMsgArray[lenSingleMsgArrayIndex][2]; curMsgLenUpLimit2 = lenSingleMsgArray[lenSingleMsgArrayIndex][0] + lenSingleMsgArray[lenSingleMsgArrayIndex][1]; if (lenSingleMsgArrayIndex == 0) { if ( $("#inputContent").val().charCodeAt(i) == 94 || $("#inputContent").val().charCodeAt(i) == 123 || $("#inputContent").val().charCodeAt(i) == 125 || $("#inputContent").val().charCodeAt(i) == 92 || $("#inputContent").val().charCodeAt(i) == 91 || $("#inputContent").val().charCodeAt(i) == 126 || $("#inputContent").val().charCodeAt(i) == 93 || $("#inputContent").val().charCodeAt(i) == 124 || $("#inputContent").val().charCodeAt(i) == 8364 ) { curCharSpecial = 1; //special character , etc { } [ ] ; } } else { lenTotalAddTemp = 0; } if ( (i + 1 + lenTotalAddTemp + curCharSpecial) > lenMsgArray[lenSingleMsgArrayIndex]) { curMsgIndexLenLeft = 0; curMsgIndex = 5; if (curCharSpecial == 1) { lenSingleAddInGSM7Ext[4]++; } break; } else if ( (i + 1 + lenTotalAddTemp + curCharSpecial) > curMsgLenUpLimit4 ) { curMsgIndexLenLeft = lenMsgArray[lenSingleMsgArrayIndex] - (lenTotalNow + lenTotalAddTemp + curCharSpecial); curMsgIndex = 5; if (curCharSpecial == 1) { lenSingleAddInGSM7Ext[4]++; } } else if ( (i + 1 + lenTotalAddTemp + curCharSpecial) > curMsgLenUpLimit3 ) { curMsgIndexLenLeft = curMsgLenUpLimit4 - (lenTotalNow + lenTotalAddTemp + curCharSpecial); curMsgIndex = 4; if (curCharSpecial == 1) { lenSingleAddInGSM7Ext[3]++; } } else if ( (i + 1 + lenTotalAddTemp + curCharSpecial) > curMsgLenUpLimit2 ) { curMsgIndexLenLeft = curMsgLenUpLimit3 - (lenTotalNow + lenTotalAddTemp + curCharSpecial); curMsgIndex = 3; if (curCharSpecial == 1) { lenSingleAddInGSM7Ext[2]++; } } else if ( (i + 1 + lenTotalAddTemp + curCharSpecial) > lenSingleMsgArray[lenSingleMsgArrayIndex][0] ) { curMsgIndexLenLeft = curMsgLenUpLimit2 - (lenTotalNow + lenTotalAddTemp + curCharSpecial); curMsgIndex = 2; if (curCharSpecial == 1) { lenSingleAddInGSM7Ext[1]++; } } else if ( (i + 1 + lenTotalAddTemp + curCharSpecial) <= lenSingleMsgArray[lenSingleMsgArrayIndex][0] ) { curMsgIndexLenLeft = lenSingleMsgArray[lenSingleMsgArrayIndex][0] - (lenTotalNow + lenTotalAddTemp + curCharSpecial); curMsgIndex = 1; if (curCharSpecial == 1) { lenSingleAddInGSM7Ext[0]++; } } } lenTotalAddTemp = lenSingleAddInGSM7Ext[0] + lenSingleAddInGSM7Ext[1] + lenSingleAddInGSM7Ext[2] + lenSingleAddInGSM7Ext[3] + lenSingleAddInGSM7Ext[4]; $("#inputContent").prop("maxlength", lenMsgArray[lenSingleMsgArrayIndex] - lenTotalAddTemp); if ( (lenTotalNow+lenTotalAddTemp) > lenMsgArray[lenSingleMsgArrayIndex]) { lenExceed = lenTotalNow+lenTotalAddTemp - lenMsgArray[lenSingleMsgArrayIndex]; $("#inputLen").text(n_str.lteSmsNewMsg.messageTooLongAlert.replace('%s', lenMsgArray[lenSingleMsgArrayIndex]).replace('%d', lenExceed)); $("#inputLen").css("color", "#ff0000"); return; } if(curMsgIndex != 0) { $("#inputLen").text("(" + curMsgIndexLenLeft + "/" + curMsgIndex + ")"); } else { $("#inputLen").text(""); } } $("textarea#inputContent").keyup(function() { if (/MSIE (\d+\.\d+);/.test(navigator.userAgent)) { /* I have found out that IE8 will crash on keyup, so do nothing here, instead we do it in keydown */ /* outputMsgLen(); */ } else { setTimeout(outputMsgLen, 10); } }); $("textarea#inputContent").keydown(function() { if (/MSIE (\d+\.\d+);/.test(navigator.userAgent)) { outputMsgLen(); } else { } }); var pageSize = 6; let chatBox = document.getElementById("chatBox") var currentPage = 0; var numRows = msgPageListGlobal[indexGlobal].msgCount; var numPages = Math.ceil(numRows / pageSize); //讯息获取 function fetchMessages(callback){ currentPage += 1; $.dm.set({ oid: "DEV2_LTE_SMS_MSGBOX", data: {"ConvsatId": msgPageListGlobal[indexGlobal].index, "PageNumber": currentPage, "TotalNumber": numRows, }, callback: { success: function() { var showContent= ""; $.dm.getList({ oid: "DEV2_LTE_SMS_MSGENTRY", data: {}, callback: { success: function(data) { let newMsgs = data.map(item =>{ showContent = doEscapeChar(item.content); this.content = showContent; return { content: $.htmlEncode(showContent), address: msgPageListGlobal[indexGlobal].phoneNumber, date: this.time, type: this.direction == 0 ? "OUTBOX" : "INBOX" }; }); callback(newMsgs); } } }); } } }); } //渲染讯息 function renderMessages(msgs, insertTop = false){ msgs.forEach(msg => { var wrapper = document.createElement("div"); wrapper.className = "msg " + (msg.type === "INBOX" ? "inbox" : "outbox"); var info = document.createElement("div"); info.className = "msg-info"; info.textContent = msg.type === "INBOX" ? msg.address + " | " + msg.date : msg.date; var div = document.createElement("div"); div.textContent = msg.content; wrapper.appendChild(info); wrapper.appendChild(div); console.log(wrapper); if (insertTop){ chatBox.insertBefore(wrapper, chatBox.firstChild);//firstchilid } else{ chatBox.appendChild(wrapper); } }); } function loadInitial() { fetchMessages(function(newMsgs){ renderMessages(newMsgs); chatBox.scrollTop = chatBox.scrollHeight; }); } function init() { $.addLoading(); $('#inputLen').TPAria('role', 'alert').TPAria('aria-live', 'polite'); //初始化页面,加载对应内容 $("#t_et").text($.tpLang.lteSmsConvsat_nstr.t_et); loadInitial(); $.removeLoading(); } chatBox.addEventListener("scroll", function(){ if (chatBox.scrollTop === 0) { if (currentPage >= numPages) { $("#loadTip").text("No more messges"); return; } $.addLoading(); var oldHeight = chatBox.scrollHeight; fetchMessages(function(newMsgs){ renderMessages(newMsgs, true); var newHeight = chatBox.scrollHeight; chatBox.scrollTop = newHeight - oldHeight; $.removeLoading(); }); } }); $("#chatBox").on("scroll", function(){ if ($(this).scrollTop() == 0){ if (currentPage >= numPages) { $("#loadTip").text("No more messges"); return; } $.addLoading(); var oldHeight = chatBox.scrollHeight; fetchMessages(function(newMsgs){ renderMessages(newMsgs, true); var newHeight = chatBox.scrollHeight; chatBox.scrollTop = newHeight - oldHeight; $.removeLoading(); }); } }); $("#back").click(function() { $.confirm(c_str.isDoNotSaveStr, function(ret) { $.loadMain("lteSmsAllMsg.htm"); } ); }); function checkPhoneNum(phoneNumStr) { var subStrTmp; var charFstTmp; var errSign = 0; if(phoneNumStr.indexOf(';') != -1 || phoneNumStr.indexOf(',') != -1) { errSign = 1; $.alert(ERR_LTE_SMS_PHONE_NUM_ONE); } else if (phoneNumStr.length >= 21 || phoneNumStr.length <= 0) { errSign = 1; $.alert(ERR_LTE_SMS_PHONE_NUM_LEN); } else { charFstTmp = phoneNumStr.charAt(0); if (charFstTmp != "+" && !$.isnum(charFstTmp)) { errSign = 1; $.alert(ERR_LTE_SMS_PHONE_NUM_FORMAT); } else if (charFstTmp == "+") { subStrTmp = phoneNumStr.substring(1, phoneNumStr.length); if (!$.isnum(subStrTmp)) { errSign = 1; $.alert(ERR_LTE_SMS_PHONE_NUM_FORMAT); } } else { if (!$.isnum(phoneNumStr)) { errSign = 1; $.alert(ERR_LTE_SMS_PHONE_NUM_FORMAT); } } } if (errSign == 1) { var element = $("#toNumber"); if (element) { element.focus(); element.select(); } return false; } return true; } $("#save").click(function() { var toNumStr; var unencodecontStr; var contentStr; var lenTotalAddTemp = 0; toNumStr = msgPageListGlobal[indexGlobal].phoneNumber; unencodecontStr = $("#inputContent").val(); contentStr = doEscapeCharEncode(unencodecontStr); if (!checkPhoneNum(toNumStr)) { return false; } if (unencodecontStr=="") { $.alert(ERR_LTE_SMS_MSG_EMPTY); return false; } lenTotalAddTemp = lenSingleAddInGSM7Ext[0] + lenSingleAddInGSM7Ext[1] + lenSingleAddInGSM7Ext[2] + lenSingleAddInGSM7Ext[3] + lenSingleAddInGSM7Ext[4]; if (contentStr.length + lenTotalAddTemp > lenMsgArray[lenSingleMsgArrayIndex]) { $.alert(ERR_LTE_SMS_MSG_TOO_LONG); $("#inputContent").focus(); $("#inputContent").select(); return; } $.addLoading($(this)); if( !($.mainParam && optPageGlobal == 2 && msgPageListGlobal[indexGlobal].phoneNumber == toNumStr && msgPageListGlobal[indexGlobal].lastMsgContent == contentStr) ) { $.dm.set({ oid: "DEV2_LTE_SMS_SENDNEWMSG", data: { "index": 2,//2表示存信息 "to": toNumStr, "textContent": contentStr }, callback: { success: function() { $.removeLoading(); $.lteSmsTips(1, s_str.msgSaveSuc); $.reload(); }, fail: function() { $.removeLoading(); $.lteSmsTips(0, s_str.msgSaveFail); } } }); } else { $.removeLoading(); $.lteSmsTips(1, s_str.msgSaveSuc); $.reload(); } }); var retryTimer; function smsSendResult(){ $.dm.get({ oid: "DEV2_LTE_SMS_SENDNEWMSG", callback: { success: function (data) { if (1 == data.sendResult) { if (retryTimer != "undefined") clearTimeout(retryTimer); $.removeLoading(); $.lteSmsTips(1, s_str.msgSentSuc); $.reload(); } else if (2 == data.sendResult) { if (retryTimer != "undefined") clearTimeout(retryTimer); $.removeLoading(); $.lteSmsTips(0, s_str.msgSentBusy, 1800); } else if (3 == data.sendResult) { //msg on sending retryTimer = $.timeout(smsSendResult, 500); } else { //fail: data.sendResult = 0 $.removeLoading(); clearTimeout(retryTimer); $.lteSmsTips(0, s_str.msgSentFail); //$.reload(); } }, fail: function () { $.removeLoading(); clearTimeout(retryTimer); $.lteSmsTips(0, s_str.msgSentFail); $.reload(); } } }); } $("#send").click(function() { var toNumStr; var unencodecontStr; var contentStr; var lenTotalAddTemp = 0; toNumStr = msgPageListGlobal[indexGlobal].phoneNumber; unencodecontStr = $("#inputContent").val(); contentStr = doEscapeCharEncode(unencodecontStr); if (!checkPhoneNum(toNumStr)) { return false; } if (unencodecontStr=="") { $.alert(ERR_LTE_SMS_MSG_EMPTY); return false; } lenTotalAddTemp = lenSingleAddInGSM7Ext[0] + lenSingleAddInGSM7Ext[1] + lenSingleAddInGSM7Ext[2] + lenSingleAddInGSM7Ext[3] + lenSingleAddInGSM7Ext[4]; TotalLen = contentStr.length + lenTotalAddTemp; if (TotalLen > lenMsgArray[lenSingleMsgArrayIndex]) { $.alert(ERR_LTE_SMS_MSG_TOO_LONG); $("#inputContent").focus(); $("#inputContent").select(); return; } function doSend() { $.dm.set({ oid: "DEV2_LTE_SMS_SENDNEWMSG", data: { "index": 1, "to": toNumStr, "textContent": contentStr }, callback: { success: function() { smsSendResult(); } } }); } $.addLoading($(this)); doSend(); }); $.tpInit(init); })(); </script> <div style="display: flex; align-items: center; gap: 10px;"> <button type="submit" class="blue inline T_back" id="back" style="cursor:pointer;">Back</button> <h3 id="t_et">Conversation List</h3> </div> <div id="chatContainer"> <div id = "chatBox"> <div id = "loadTip">上滑加载更多...</div> </div> <div id="editor"> <label id="inputLen" class="label-title m" style="vertical-align: top;margin-top:8px;"></label> <textarea id="inputContent" placeholder="输入讯息内容..." maxlength="1000"></textarea> <div id="editorButtons"> <button id="save" class="btn">Save</button> <button id="send" class="btn">Send</button> </div> </div> </div> <script type="text/javascript"> (function() {})(); </script> 分析上述代码
09-27
<!DOCTYPE html> <html lang="zh-CN"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>学生信息统计列表</title> <style> * { box-sizing: border-box; margin: 0; padding: 0; font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif; } body { background: linear-gradient(120deg, #e0f7fa, #bbdefb); min-height: 100vh; display: flex; justify-content: center; align-items: center; padding: 20px; } .container { max-width: 800px; width: 100%; padding: 20px; text-align: center; } .title { background: #1565c0; color: white; padding: 15px; border-radius: 5px; margin-bottom: 30px; box-shadow: 0 4px 8px rgba(0,0,0,0.2); } table { border-collapse: collapse; width: 100%; margin: 0 auto; background-color: white; box-shadow: 0 5px 15px rgba(0,0,0,0.1); border-radius: 5px; overflow: hidden; } th { background: #1976d2; color: white; padding: 15px; font-weight: bold; font-size: 1.1rem; } td { padding: 12px 15px; border: 1px solid #b0bec5; } /* 表格边框加粗 */ table { border: 3px solid #094d8d; } /* 第一列左对齐 */ td:first-child { text-align: left; } /* 第二列图标样式 */ .check { color: #2e7d32; font-weight: bold; } .cross { color: #c62828; font-weight: bold; } /* 行样式 */ tr:nth-child(even) { background-color: #f5f9ff; } tr:hover { background-color: #e3f2fd; } .explanation { background-color: white; border-left: 4px solid #1976d2; padding: 15px; margin-top: 30px; text-align: left; border-radius: 0 5px 5px 0; } .explanation h3 { color: #1976d2; margin-bottom: 10px; } .explanation ul { margin-left: 20px; line-height: 1.6; } .explanation li { margin-bottom: 8px; } .footer { margin-top: 25px; color: #546e7a; font-size: 0.9rem; } </style> </head> <body> <div class="container"> <div class="title"> <h1>学生信息统计列表</h1> </div> <table> <thead> <tr> <th>科目</th> <th>合格结果</th> <th>备注</th> </tr> </thead> <tbody> <tr> <td>数学</td> <td class="check">✓</td> <td>考试形式是笔试</td> </tr> <tr> <td>语文</td> <td class="cross">✗</td> <td>文笔不太行,需加强</td> </tr> <tr> <td>英语</td> <td class="check">✓</td> <td>口语成绩太差</td> </tr> </tbody> </table> </div> </body> </html> 以上是我需要使用java显示的页面内容,目前我有一个Result对象列表,每个对象内含有一个布尔类型的check字段,information字符串字段,其中第一列内容是固定内容,第二列的对号叉号需要根据check来动态显示,第三列内容是使用每个对象的information的值来填充,帮我生成一个完整的java实现代码
最新发布
11-04
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值