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标签外部,表格会乱;移到 "> 外面表格会乱;

相关推荐
lee_curry6 小时前
第四章 jvm中的垃圾回收器
java·jvm·垃圾收集器
九转成圣7 小时前
Java 性能优化实战:如何将海量扁平数据高效转化为类目字典树?
java·开发语言·json
SmartRadio7 小时前
ESP32-S3 双模式切换实现:兼顾手机_路由器连接与WiFi长距离通信
开发语言·网络·智能手机·esp32·长距离wifi
laowangpython8 小时前
Rust 入门:GitHub 热门内存安全编程语言
开发语言·其他·rust·github
我叫汪枫8 小时前
在后台管理系统中,如何递归和选择保留的思路来过滤菜单
开发语言·javascript·node.js·ecmascript
_.Switch8 小时前
东方财富股票数据JS逆向:secids字段和AES加密实战
开发语言·前端·javascript·网络·爬虫·python·ecmascript
软件技术NINI8 小时前
webkit简介及工作流程
开发语言·前端·javascript·udp·ecmascript·webkit·yarn
Brendan_0018 小时前
JavaScript的Stomp.over
开发语言·javascript·ecmascript
念2348 小时前
f5 shape分析
开发语言·javascript·ecmascript
苍穹之跃8 小时前
某量JS逆向
开发语言·javascript·ecmascript