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

相关推荐
川石课堂软件测试1 天前
全链路Controller压测负载均衡
android·运维·开发语言·python·mysql·adb·负载均衡
程序员清风1 天前
Dubbo RPCContext存储一些通用数据,这个用手动清除吗?
java·后端·面试
摇滚侠1 天前
Spring Boot 3零基础教程,条件注解,笔记09
java·spring boot·笔记
南瓜小米粥、1 天前
从可插拔拦截器出发:自定义、注入 Spring Boot、到生效路径的完整实践(Demo 版)
java·spring boot·后端
Huangmiemei9111 天前
Spring Boot项目的常用依赖有哪些?
java·spring boot·后端
杨福瑞1 天前
C语言⽂件操作讲解(总)
c语言·开发语言
天天摸鱼的java工程师1 天前
接口联调总卡壳?先问自己:真的搞清楚 HTTP 的 Header 和 Body 了吗?
java·后端
真的想不出名儿1 天前
上传头像到腾讯云对象存储-前端基于antdv
java·数据库·腾讯云
Nan_Shu_6141 天前
学习SpringBoot
java·spring boot·后端·学习·spring
JAVA学习通1 天前
SpringBoot Layui ThymeLeaf 一点点学习心得
java·spring