jsp 的div表格示例

html 复制代码
<%@page contentType="text/html;charset=gbk" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>jsp div 表格示例 </title>
    </head>
    <body>

        <div style="width: 99%; top: 5px; position:  absolute; margin: 0px; ">
            <div id="vartable" style=" width: 800px; display:  table; margin: 0 auto; border-collapse:  collapse;">


                <%  for(int i=0;i<15;i++){  %>

                <div  id="vtable-row" style="display:  table-row; height: 30px;  border-collapse:  collapse; border-top:  #021e98 solid thin; border-left: #021e98 solid thin;

                      <% //如果是最后一行使用JSP内置对象out输出border-bottom属性,为表格显示底部框线。

                        if(i==14){
                            out.println("border-bottom:  #021e98 solid thin;");
                        }  %>   ">

                    <div style="display:  table-cell; border-right: #021e98 solid thin;  text-align:  center; vertical-align:  middle;">
                        <div> 1</div>
                    </div>

                    <div style="display:  table-cell;  border-right: #021e98 solid thin;  text-align:  center; vertical-align:  middle;">
                        <div> 2</div>
                    </div>

                    <div style="display:  table-cell;  border-right: #021e98 solid thin; text-align:  center; vertical-align:  middle;">
                        <div> 3</div>
                    </div>

                    <div style="display:  table-cell; border-right: #021e98 solid thin; text-align:  center; vertical-align:  middle;">
                        <div> 4</div>
                    </div>

                </div>

                <%  } %>

            </div>
        </div>

    </body>
</html>

这有几个问题;

它是用div赋予以下属性来形成表格、表格的行、表格的单元格;

display: table

display: table-row;

display: table-cell;

这个以前没用过;常常都是display: block,或者 display: none;

if(i==14){

out.println("border-bottom: #021e98 solid thin;");

} %>

这几句是写到div元素的标签内部,<div id="vtable-row" ...>这个div的结束标签的内部,它是这样的,

if(i==14){

out.println("border-bottom: #021e98 solid thin;");

} %> ">

代码没有问题;以前也没见这样写法;

如果移到div标签外部,表格会乱;移到 "> 外面表格会乱;

相关推荐
马优晨3 分钟前
Freemarker 完整讲解(后端 Java 模板引擎)
java·开发语言·freemarker·freemarker 完整讲解·freemarker模板引擎
人邮异步社区2 小时前
怎么把C语言学到精通?
c语言·开发语言
心平气和量大福大2 小时前
C#-WPF-控件-TextBox 数据绑定
开发语言·c#·wpf
ttwuai3 小时前
Cursor 生成 CRUD 后,Go 后台接口别只测 200:JWT、RBAC 和 tenant_id 怎么验
开发语言·后端·golang
维天说3 小时前
CLI-Switch 2026年3月版历史设计:Hook、TTY 隔离与 JSON 状态
java·服务器·json
এ慕ོ冬℘゜3 小时前
前端基础:什么是时间戳?JS获取时间戳三种方法与实战用途
开发语言·前端·javascript
执明wa3 小时前
LayoutInflater详解: XML是如何变成View的?
android·xml·开发语言·android studio
一次旅行3 小时前
Python+大模型端到端自动化日报系统
开发语言·python·自动化
Zane19943 小时前
并发 vs 并行:别再傻傻分不清了,一文讲透 Java 并发编程的第一课
java·后端
噢,我明白了4 小时前
java中Excel的导入和导出(EasyExcel)
java·开发语言·excel