html - 边框未正确呈现,布局周围需要干净的边框

标签 html css

我正在处理工资单布局,我几乎完成了设计,我正在寻找它周围漂亮和体面的边框,那里的边框似乎是白色或奶油色,但是当我改变颜色时,它看起来很糟糕并且呈现不佳。

<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
    <head>
        <title>Salary Slip : ${initParam['applicationName']}</title>
        <%@include file="../common/include.jsp" %>
        <style>
            table th
            {
                background-color:#448AFF;
            }
            #empName
            {
                background-color:#ffffff;
            }

            #woSpTable > thead > tr:nth-child(2) > th:nth-child(1),
            #woSpTable > thead > tr:nth-child(2) > th:nth-child(2),
            #woSpTable > thead > tr:nth-child(2) > th:nth-child(3)
            {
                color:#ffffff;
            }
            #example-1 > tbody > tr:nth-child(1) > th:nth-child(1),
            #example-1 > tbody > tr:nth-child(1) > th:nth-child(2),
            #example-1 > tbody > tr:nth-child(1) > th:nth-child(3),
            #example-1 > tbody > tr:nth-child(1) > th:nth-child(4),
            #example-1 > tbody > tr:nth-child(1) > th:nth-child(5)
            {
                color:#ffffff;
            }
            #woSpTable >tbody >tr >td:nth-child(1),
            #woSpTable >tbody >tr >td:nth-child(3),
            #woSpTable >tbody >tr >td:nth-child(5),
            #woSpTable >tbody >tr >td:nth-child(7),
            #woSpTable >tbody >tr >td:nth-child(9)
            {
                font-weight: bold;
            }
            .fontSizeNetPay
            {
                font-size: 18px;
            }
            .iconDetails {
                margin-left:2%;
                float:left; 
                height:55px;
            } 

            .container2 {
                width:100%;
                height:auto;
                padding:1%;
            }

        </style>
    </head>
    <body class="page-body skin-facebook horizontal-menu-skin-facebook user-info-navbar-skin-navy">
        <%@include file="../common/top_settings.jsp" %>
        <div class="page-container" >
            <%@include file="../common/left_menu.jsp" %>
            <div class="main-content">
                <%@include file="../common/header.jsp" %>
                <section class="profile-env" class="border">
                    <div class="panel-heading " style="text-align: center">
                        <h2>SALARY SLIP</h2>
                    </div>
                    <div class="panel panel-body">
                        <div class='container2'>
                            <div>
                                <img src="<%=ProjectConfig.resourcePath%><%=ProjectConfig.departmentLogoDark%>" height="55" class="pull-right iconDetails"style="margin-bottom:10px; "/>
                            </div>  
                            <div >
                                <h4 style="margin-top:10px">Employee Salary Detail For Month-Year(${yearMonth})</h4>
                            </div>
                        </div>
                        <table id="woSpTable"  align="center" class="table table-bordered fontsize" >

                            <thead>
                                <tr><th colspan="7" id="empName" style="border: 0.5px solid #000000" > SUPER ADMINISTRATOR </th></tr>
                                <tr>
                                    <th colspan="2" bgcolor="#448AFF"> Employee Details</th>
                                    <th colspan="2" bgcolor="#448AFF">Payment & Leave Details</th>
                                    <th colspan="2" bgcolor="#448AFF">Location Details</th>
                                </tr>
                            </thead>
                            <tbody>
                                <tr>
                                    <td class="tdFontWeight">Employee Code</td>
                                    <td>12345678</td>
                                    <td>Bank details</td>
                                    <td>Axis Bank</td>
                                    <td>Official Location</td>
                                    <td>AKVN Bhopal</td>
                                </tr>
                                <tr>
                                    <td>Grade </td>
                                    <td> Class 1 Officer</td>
                                    <td>Account No.</td>
                                    <td>383702104568</td>
                                    <td>Bank Branch</td>
                                    <td>Main Branch</td>
                                </tr>
                                <tr>
                                    <td>Pan No </td>
                                    <td>ADEP123456</td>
                                    <td>Paid For Month</td>
                                    <td>November 2018</td>
                                    <td>Account No.</td>
                                    <td>383702104568</td>
                                </tr>
                            </tbody>

                        </table>
                        <table  align="center" class="table table-bordered fontsize" >
                            <tr> 
                                <td width="50%" class="no-padding">
                                    <table id="example-1"  class="table fontSize table-bordered">
                                        <tr style="font-weight: bolder">
                                            <th style="width:inherit; background-color:#448AFF">Earning</th>
                                            <th style="width:inherit; background-color: #448AFF"> Pay Mode </th>
                                            <th style="text-align: right; background-color: #448AFF">Amount</th>
                                        </tr>
                                        <s:url var="i" value="1" />
                                        <tr>
                                            <th class="form-control" style="width:inherit">Basic Salary</th>
                                            <td style="text-align: right">Online</td>
                                            <td style="text-align: right">54000</td>
                                        </tr>
                                        <tr>
                                            <th class="form-control" style="width:inherit">House Rent Allowance</th>
                                            <td style="text-align: right">Online</td>
                                            <td style="text-align: right">5400</td>
                                        </tr>
                                        <tr>
                                            <th class="form-control" style="width:inherit">Dearness Allowance</th>
                                            <td style="text-align: right">Online</td>
                                            <td style="text-align: right">5400</td>
                                        </tr>
                                        <tr>
                                            <th class="form-control" style="width:inherit">Travelling Allowance</th>
                                            <td style="text-align: right">Online</td>
                                            <td style="text-align: right">5400</td>
                                        </tr>
                                        <s:url var="i" value="${i+1}"/>
                                    </table>
                                </td>

                                <td width="50%" class="no-padding">
                                    <table id="example-1" class="table fontSize table-bordered dataTable"  >
                                        <tr style="font-weight: bolder">
                                            <th style="width:inherit; background-color: #448AFF">Deduction</th>
                                            <th style="text-align: right; background-color: #448AFF">Amount</th>
                                        </tr>
                                        <s:url var="i" value="1" />
                                        <%--<c:forEach items="${empSalaryDeductionList}" var="el">--%>
                                        <%--<c:if test="${el.payCode!='998'}">--%>
                                        <tr>
                                            <th class="form-control" style="width:inherit">${el.payCodeDesc}</th>
                                            <td style="text-align: right"  >${el.payMode == 2 ?  el.newTaxAmount : '0'}</td>
                                            <!--<td style="text-align: center" > ${el.payMode == 5 || el.payMode == 4  ? el.newTaxAmount : '0' }</td>-->
                                        </tr>
                                        <tr>
                                            <th class="form-control" style="width:inherit">PF</th>
                                            <td style="text-align: right">2000</td>
                                        </tr>
                                        <s:url var="i" value="${i+1}"/>
                                    </table>
                                </td>
                            </tr>
                            <tfoot>
                                <tr>
                                    <td>
                                        <table class="table table-bordered">
                                            <tr>
                                                <td colspan="2">Total Earning (INR)</td>
                                                <td align="right">70,200</td>
                                            </tr>
                                        </table>
                                    </td>
                                    <td>
                                        <table class="table table-bordered">
                                            <tr>
                                                <td>Total Deduction (INR)</td>
                                                <td style="text-align: right">2000</td>
                                            </tr>
                                        </table>
                                    </td>
                                </tr>
                            </tfoot>
                        </table>
                        <table id="example-1" class="table fontSize table-bordered dataTable"  >
                            <td align="right"> 
                                <table id="example-1" style="width:300px; height: 50px;" class="table fontSizeNetPay table-bordered dataTable">
                                    <tr style="font-weight: bolder">
                                        <th style="width:inherit; background-color: #448AFF">NET PAY<small> (INR)</small></th>
                                        <th style="text-align: right">68,200</th>
                                    </tr>
                                </table>
                            </td>
                        </table>
                    </div>
                </section>
            </div>  
        </div>
        <div class="clearfix"></div>
        <%@include file="../common/footer.jsp" %>
</body>
</html>

我想在我的整个布局中添加边框,如果你仔细观察 html 代码,你会发现 3 个或更多表,其中一个是主要的,其他的嵌套在 td

我为每个部分使用了不同的表格标签,

现在我想要每张 table 都应该同样合理的边框,请帮助我

查看代码笔

https://codepen.io/anon/pen/gQjqqz

最佳答案

你是这个意思吗?

html:

<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
    <head>
        <title>Salary Slip : ${initParam['applicationName']}</title>
        <%@include file="../common/include.jsp" %>
        <style>
            table th
            {
                background-color:#448AFF;
            }
            #empName
            {
                background-color:#ffffff;
            }

            #woSpTable > thead > tr:nth-child(2) > th:nth-child(1),
            #woSpTable > thead > tr:nth-child(2) > th:nth-child(2),
            #woSpTable > thead > tr:nth-child(2) > th:nth-child(3)
            {
                color:#ffffff;
            }
            #example-1 > tbody > tr:nth-child(1) > th:nth-child(1),
            #example-1 > tbody > tr:nth-child(1) > th:nth-child(2),
            #example-1 > tbody > tr:nth-child(1) > th:nth-child(3),
            #example-1 > tbody > tr:nth-child(1) > th:nth-child(4),
            #example-1 > tbody > tr:nth-child(1) > th:nth-child(5)
            {
                color:#ffffff;
            }
            #woSpTable >tbody >tr >td:nth-child(1),
            #woSpTable >tbody >tr >td:nth-child(3),
            #woSpTable >tbody >tr >td:nth-child(5),
            #woSpTable >tbody >tr >td:nth-child(7),
            #woSpTable >tbody >tr >td:nth-child(9)
            {
                font-weight: bold;
            }
            .fontSizeNetPay
            {
                font-size: 18px;
            }
            .iconDetails {
                margin-left:2%;
                float:left; 
                height:55px;
            } 

            .container2 {
                width:100%;
                height:auto;
                padding:1%;
            }

        </style>
    </head>
    <body class="page-body skin-facebook horizontal-menu-skin-facebook user-info-navbar-skin-navy">
        <%@include file="../common/top_settings.jsp" %>
        <div class="page-container" >
            <%@include file="../common/left_menu.jsp" %>
            <div class="main-content">
                <%@include file="../common/header.jsp" %>

 <!-- don't say class twice -- <section class="profile-env" class="border"> -->
 <!-- instead say it once and separate class names with a space: -->
                     <section class="profile-env border">

                    <div class="panel-heading " style="text-align: center">
                        <h2>SALARY SLIP</h2>
                    </div>
                    <div class="panel panel-body">
                        <div class='container2'>
                            <div>
                                <img src="<%=ProjectConfig.resourcePath%><%=ProjectConfig.departmentLogoDark%>" height="55" class="pull-right iconDetails"style="margin-bottom:10px; "/>
                            </div>  
                            <div >
                                <h4 style="margin-top:10px">Employee Salary Detail For Month-Year(${yearMonth})</h4>
                            </div>
                        </div>
                        <table id="woSpTable"  align="center" class="table table-bordered fontsize" >

                            <thead>
                                <tr><th colspan="7" id="empName" style="border: 0.5px solid #000000" > SUPER ADMINISTRATOR </th></tr>
                                <tr>
                                    <th colspan="2" bgcolor="#448AFF"> Employee Details</th>
                                    <th colspan="2" bgcolor="#448AFF">Payment & Leave Details</th>
                                    <th colspan="2" bgcolor="#448AFF">Location Details</th>
                                </tr>
                            </thead>
                            <tbody>
                                <tr>
                                    <td class="tdFontWeight">Employee Code</td>
                                    <td>12345678</td>
                                    <td>Bank details</td>
                                    <td>Axis Bank</td>
                                    <td>Official Location</td>
                                    <td>AKVN Bhopal</td>
                                </tr>
                                <tr>
                                    <td>Grade </td>
                                    <td> Class 1 Officer</td>
                                    <td>Account No.</td>
                                    <td>383702104568</td>
                                    <td>Bank Branch</td>
                                    <td>Main Branch</td>
                                </tr>
                                <tr>
                                    <td>Pan No </td>
                                    <td>ADEP123456</td>
                                    <td>Paid For Month</td>
                                    <td>November 2018</td>
                                    <td>Account No.</td>
                                    <td>383702104568</td>
                                </tr>
                            </tbody>

                        </table>
                        <table  align="center" class="table table-bordered fontsize" >
                            <tr> 
                                <td width="50%" class="no-padding">
                                    <table id="example-1"  class="table fontSize table-bordered">
                                        <tr style="font-weight: bolder">
                                            <th style="width:inherit; background-color:#448AFF">Earning</th>
                                            <th style="width:inherit; background-color: #448AFF"> Pay Mode </th>
                                            <th style="text-align: right; background-color: #448AFF">Amount</th>
                                        </tr>
                                        <s:url var="i" value="1" />
                                        <tr>
                                            <th class="form-control" style="width:inherit">Basic Salary</th>
                                            <td style="text-align: right">Online</td>
                                            <td style="text-align: right">54000</td>
                                        </tr>
                                        <tr>
                                            <th class="form-control" style="width:inherit">House Rent Allowance</th>
                                            <td style="text-align: right">Online</td>
                                            <td style="text-align: right">5400</td>
                                        </tr>
                                        <tr>
                                            <th class="form-control" style="width:inherit">Dearness Allowance</th>
                                            <td style="text-align: right">Online</td>
                                            <td style="text-align: right">5400</td>
                                        </tr>
                                        <tr>
                                            <th class="form-control" style="width:inherit">Travelling Allowance</th>
                                            <td style="text-align: right">Online</td>
                                            <td style="text-align: right">5400</td>
                                        </tr>
                                        <s:url var="i" value="${i+1}"/>
                                    </table>
                                </td>

                                <td width="50%" class="no-padding">
                                    <table id="example-1" class="table fontSize table-bordered dataTable"  >
                                        <tr style="font-weight: bolder">
                                            <th style="width:inherit; background-color: #448AFF">Deduction</th>
                                            <th style="text-align: right; background-color: #448AFF">Amount</th>
                                        </tr>
                                        <s:url var="i" value="1" />
                                        <%--<c:forEach items="${empSalaryDeductionList}" var="el">--%>
                                        <%--<c:if test="${el.payCode!='998'}">--%>
                                        <tr>
                                            <th class="form-control" style="width:inherit">${el.payCodeDesc}</th>
                                            <td style="text-align: right"  >${el.payMode == 2 ?  el.newTaxAmount : '0'}</td>
                                            <!--<td style="text-align: center" > ${el.payMode == 5 || el.payMode == 4  ? el.newTaxAmount : '0' }</td>-->
                                        </tr>
                                        <tr>
                                            <th class="form-control" style="width:inherit">PF</th>
                                            <td style="text-align: right">2000</td>
                                        </tr>
                                        <s:url var="i" value="${i+1}"/>
                                    </table>
                                </td>
                            </tr>
                            <tfoot>
                                <tr>
                                    <td>
                                        <table class="table table-bordered">
                                            <tr>
                                                <td colspan="2">Total Earning (INR)</td>
                                                <td align="right">70,200</td>
                                            </tr>
                                        </table>
                                    </td>
                                    <td>
                                        <table class="table table-bordered">
                                            <tr>
                                                <td>Total Deduction (INR)</td>
                                                <td style="text-align: right">2000</td>
                                            </tr>
                                        </table>
                                    </td>
                                </tr>
                            </tfoot>
                        </table>
                        <table id="example-1" class="table fontSize table-bordered dataTable"  >
                            <td align="right"> 
                                <table id="example-1" style="width:300px; height: 50px;" class="table fontSizeNetPay table-bordered dataTable">
                                    <tr style="font-weight: bolder">
                                        <th style="width:inherit; background-color: #448AFF">NET PAY<small> (INR)</small></th>
                                        <th style="text-align: right">68,200</th>
                                    </tr>
                                </table>
                            </td>
                        </table>
                    </div>
                </section>
            </div>  
        </div>
        <div class="clearfix"></div>
        <%@include file="../common/footer.jsp" %>
</body>
</html>

CSS:

 html {
  background:brown;
}

/* changed selectors */
.table-bordered,
.border {
  border:1px solid yellow;
  margin-bottom:2em;
}

https://codepen.io/carolmckayau/pen/Oawqbd

关于html - 边框未正确呈现,布局周围需要干净的边框,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53493338/

相关文章:

javascript - 调用不同的 JavaScript 函数

html - 表格延伸过去的容器

html - 并排对齐图像

html - IE 8 上带有背景颜色的超链接( anchor )按钮不起作用

css - 垫表列宽度在包含输入时不会改变

javascript - 在 SVG 中以特定 Angular 放置路径

javascript - jQuery .remove() 不工作,而其他内置函数是

html - 在 Firefox 中使用列时右侧 float 元素消失

html - ie8 - 当图像只有最大宽度时,将文本宽度限制为图像宽度

javascript - style.setProperty 不呈现