table和div设置height:100%无效的完美解决方法

本文探讨了解决HTML中table和div元素高度设为100%无效的问题。对于table,移除DOCTYPE声明即可;而对于div,则需设置html及body的高度为100%。

刚接触网页排版的新手,常出现这种情况:设置table和div的高height="100%"无效,使用CSS来设置height:"100%"也无效,为什么会这样呢?解决height:100%无效,table和div的解决方法并不相同。

首先说一下table,他比较容易解决,当我们使用Dreamweaver来制作网页,新建一张网页,通常在代码头部会有类似以下的代码:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
没错,你猜对了,问题就出在这里,你试着把这短代码删除,然后再刷新一下网页,你就会看到所有table以你的设置height="100%"的展示!
这段代码是告诉浏览器你的网页是遵循什么标准的,如上面的“W3C”标准,删除掉一般是不影响的。
下面说一下div,div和table一样,如果要实现width:100%是很容易的,但要div的height:"100%",它就不大听话了,其实不是它不听话,是你不知道让它听话的方法。如下代码:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>测试</title>
</head>
<body>
<div style="height:100%"></div>
</body>
</html>
就算和Table一样去掉头部的那段代码也不能100%显示,原因很简单,你让div的height="100%",执行网页时,css先执行到,而整个网页中的内容还没有完全载入,是获取不到div外面的<body>等的高度的,所以height="100%"也就不能如愿显示了。加上
body{height:100%}
就轻松解决啦,一开始就让body以100%显示,他的下级div自然就100%的,不过对于FF浏览器还应该把HTML也先给height:100%,即
html,body{height:100%}

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>
  <title> New Document </title>
  <style type="text/css">
    html { height: 100%}
    body {height:100%;margin:0px;padding:0px}
    table{height: 100%;width: 100%;}
  </style>
 </head>

 <body>
    <table border=1>
        <tr>
            <td>
                <ul>
                    <li>12
                    <li>34
                </ul>
            </td>
            <td>
                <iframe name="" src="" width="100%" height="100%"></iframe>
            </td>
        </tr>
    </table>
 </body>
</html>
 

本文来自优快云博客,转载请标明出处:http://blog.youkuaiyun.com/majin_com/archive/2011/04/12/6318499.aspx

 

<template> <c-modal v-model:open="open" title="" @ok="handleOrderOk" width="1600px" :footer="null"> <div style="padding-bottom: 15px"> <a-button key="back" @click="handleCancel" v-if="isFooter">取消</a-button> <a-button key="print" @click="handlePrint">打印</a-button> </div> <div id="printJS-form"> <div v-for="(item, index) in formState" :key="index"> <div class="order-container print-container-div" > <div class="order-top widthClass"> <div class="order-top-title"> <div class="order-top-logo"><img class="logo" src="../../../assets/cimc.png" /></div> <p class="order-top-titles">Piping Welds Positive Material Identification Report</p> <div class="order-top-QRCode" style="float: right;width: 100px"> <img style="width: 80px;weight:30px;float: right" src="/static/pipe/images/seatrium.png" /> <img style="width: 80px;weight:30px;float: right" src="/static/pipe/images/br.png" /> </div> </div> </div> <div class="printable-area widthClass"> <table class="widthClass"> <tr style="height: 30px"> <td style="width: 50%;"></td> <td style="width: 12%;font-size: 16px;border-left: 0 none !important;">Analysis Data Sheet: </td> <td style="width: 13%;font-size: 16px;border-left: 0 none !important;"> </td> <td style="width: 12%;font-size: 16px;border-left: 0 none !important;">BM*:base material</td> <td style="width: 13%;font-size: 16px;border-left: 0 none !important;"></td> </tr> </table> <table class="widthClass" style="font-size: 16px;font-weight: 400;"> <tr style="height: 30px;"> <td style="width: 28%;">Job Title:</td> <td style="width: 24%;">{{item.pringProjectNo}}</td> <td style="width: 24%;">PMI Report NO.:</td> <td style="width: 24%;"></td> </tr> <tr style="height: 30px;"> <td style="width: 28%;">Location:</td> <td style="width: 24%;">Workshop </td> <td style="width: 24%;">Date:</td> <td style="width: 24%;">{{dayjs(item.applyDate).format("YYYY-MM-DD")}}</td> </tr> <tr style="height: 30px;"> <td style="width: 28%;">Analyser Type and Model No.:</td> <td style="width: 24%;">Nition XL2</td> <td style="width: 24%;">Operators:</td> <td style="width: 24%;">Ding Guang wei</td> </tr> <tr style="height: 30px;"> <td style="width: 28%;">Analyser Serial No.:</td> <td style="width: 24%;"></td> <td style="width: 24%;">Analyser Cablibration Date:</td> <td style="width: 24%;"></td> </tr> <tr style="height: 30px;"> <td style="width: 28%;">Material Specification/Grade:</td> <td style="width: 24%;">316/316L</td> <td style="width: 24%;">PMI Procedure No.:</td> <td style="width: 24%;">I-PR-3010.2S-1351-973-YCT-001</td> </tr> </table> <table class="widthClass" style="font-size: 16px;font-weight: 400;"> <tr style="height: 30px;"> <td style="width: 5%;" rowspan="4">S/NO</td> <td style="width: 23%;" rowspan="4">Joint No.</td> <td style="width: 60%;" colspan = '10'>Alloy Content, WT%</td> <td style="width: 12%;" colspan = '2'>Result</td> </tr> <tr style="height: 30px;"> <td style="width: 6%;">Min.</td> <td style="width: 6%;">10.0</td> <td style="width: 6%;">16.0</td> <td style="width: 6%;">2.00</td> <td style="width: 6%;">NA</td> <td style="width: 6%;">NA</td> <td style="width: 6%;">NA</td> <td style="width: 6%;">NA</td> <td style="width: 6%;">NA</td> <td style="width: 6%;">NA</td> <td style="width: 6%;" rowspan="2">Accept</td> <td style="width: 6%;" rowspan="2">Reject</td> </tr> <tr style="height: 30px;"> <td style="width: 6%;">Max.</td> <td style="width: 6%;">14.0</td> <td style="width: 6%;">20.0</td> <td style="width: 6%;">3.00</td> <td style="width: 6%;">NA</td> <td style="width: 6%;">NA</td> <td style="width: 6%;">NA</td> <td style="width: 6%;">NA</td> <td style="width: 6%;">NA</td> <td style="width: 6%;">NA</td> </tr> <tr style="height: 30px;"> <td style="width: 6%;">I.D.</td> <td style="width: 6%;">Ni</td> <td style="width: 6%;">Cr</td> <td style="width: 6%;">Mo</td> <td style="width: 6%;">Cu</td> <td style="width: 6%;">NB(cb)</td> <td style="width: 6%;">Ti</td> <td style="width: 6%;">W</td> <td style="width: 6%;">C</td> <td style="width: 6%;">Other</td> <td style="width: 6%;"></td> <td style="width: 6%;"></td> </tr> </table> <table class="widthClass" style="font-size: 16px;font-weight: 400;"> <div v-for="(weldItem,index) in item.weldList" :key="item.id" style="width: 100%;"> <tr style="width: 100%;min-height: 30px;" > <td style="width: 5%; text-align: center; vertical-align: middle; display: table-cell;" rowspan="3">{{index+1}}</td> <td style="width: 23%;">{{weldItem.weldNo}}</td> <td style="width: 6%;">BM1*</td> <td style="width: 6%;"></td> <td style="width: 6%;"></td> <td style="width: 6%;"></td> <td style="width: 6%;"></td> <td style="width: 6%;"></td> <td style="width: 6%;"></td> <td style="width: 6%;"></td> <td style="width: 6%;"></td> <td style="width: 6%;"></td> <td style="width: 6%;"></td> <td style="width: 6%;"></td> </tr> <tr style="width: 100%;min-height: 30px;" > <td style="width: 23%;" >{{weldItem.weldNo}}</td> <td style="width: 6%;">Joint</td> <td style="width: 6%;"></td> <td style="width: 6%;"></td> <td style="width: 6%;"></td> <td style="width: 6%;"></td> <td style="width: 6%;"></td> <td style="width: 6%;"></td> <td style="width: 6%;"></td> <td style="width: 6%;"></td> <td style="width: 6%;"></td> <td style="width: 6%;"></td> <td style="width: 6%;"></td> </tr> <tr style="width: 100%;min-height: 30px;" > <td style="width: 23%;">{{weldItem.weldNo}}</td> <td style="width: 6%;">BM2*</td> <td style="width: 6%;"></td> <td style="width: 6%;"></td> <td style="width: 6%;"></td> <td style="width: 6%;"></td> <td style="width: 6%;"></td> <td style="width: 6%;"></td> <td style="width: 6%;"></td> <td style="width: 6%;"></td> <td style="width: 6%;"></td> <td style="width: 6%;"></td> <td style="width: 6%;"></td> </tr> </div> </table> </div> </div> <div style="page-break-after:always"></div> </div> </div> </c-modal> </template> <script setup> import {ref, reactive, onMounted} from "vue" import { print } from "@/utils/print" import * as server from "@/packages/piping/api/cpin"; import {create} from "@/utils/imgtoBase64"; import dayjs from "dayjs" const open = ref(false) const initType = ref() const totalWeight = ref(0) const formState = ref({}) const isFooter = ref(true) const orderTableState = reactive({ datasource: [] }) onMounted(() => { create("/static/mes/images/dataScreen-header-center-bg.png").then((res) => { centerImg.value = res }) }) const handleOrderOk = () => {} const init = (type, data) => { initType.value = type isFooter.value = type === "galv" console.log("data2", data) let printDatas = [] // 使用 Promise.all 等待所有异步操作完成 Promise.all(data.map(async (dataItem) => { try { const res = await server.getOrderList({ page: 0, size: 10000, orderNo: dataItem.orderNo }) let item = res.data.content[0] || {} item.weldList.forEach((weld, index) => { weld.indexNum = index + 1 }) return item } catch (error) { console.error("获取订单列表失败:", error) return {} } })).then(results => { printDatas = results formState.value = printDatas }) } const handleCancel = () => { open.value = false } const handlePrint = () => { print({ // mediaPrint:false, // noPrintSelector:'avoid-this', type: "html", printable: "printJS-form", // type: "raw-html", // printable: "test-dom", // scanStyles: false, // noHeadersAndFooters:true, maxWidth: 1500, targetStyles: ["*"], scanStyles: false, style: ` table{font-size:3px} td{font-size:10px !important} .print-container-div{ width: 1100px !important; } .widthClass{ width: 1000px; font-size:1px } .ant-descriptions-view >table{ width:100%!important; font-size:1px; } @media print { a[href]:after { content: none !important; } #footer { display: none; } } .imgInline{ display: flex;} .order-top-QRCode{float:right} .order-top-title { width: 100%; height: 50px; text-align: center; display: flex; padding-top:15px } .order-top-logo { img { margin-top:10px; width: 150px; position: absolute; left: 0; } } .order-top-titles { font-size: 18px; font-weight: bold; width: 100%; margin: 0; align:center; text-align:center; padding-top:15px; } .order-top-vice-title { width: 100%; } .logo{width:150px;height:20px} .paging{page-break-after: aways;} .order-container { width: 100%; height: 100%; position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; .order-top { width: 100%; display: flex; justify-content: center; position: relative; margin-bottom: 100px; height:400px; .order-top-title { width: 45%; height: 50px; text-align: center; display: flex; .order-top-logo { img { width: 150px; position: absolute; left: 0; } } .order-top-titles { font-size: 18px; font-weight: bold; width: 100%; margin: 0; } .order-top-vice-title { width: 100%; } } } .order-top-QRCode { display: flex; align-items: center; } .order-mid { width: calc(100%); padding-top: 15px; } .order-mod { width: calc(100% ); .order-mod-left{ width: 49%; padding: 5px 0; border-radius: 10px; background: #eef0f3; } .order-mod-right { width: 49%; padding: 5px 0; border-radius: 10px; background: #eef0f3; } .order-mod-title { //border: 1px solid #3981ee; padding: 5px; //color: #3981ee; width: 50%; display: flex; align-items: center; justify-content: center; margin: 10px auto; background: #fff; border-radius: 7px; } .order-mod-content { display: flex; align-items: center; width: 100%; margin: 10px auto; .order-mod-content-title { width: 30%; text-align: right; padding: 5px 0; } .order-mod-content-content { flex: 1; white-space: nowrap; } } } .order-bot { width: 100%; margin-top: 10px; } .order-table { //border: 1px solid black !important; // transform: scale(0.7); //width: calc(100% / 0.7); // transform-origin: top center; } } :deep(.ant-descriptions) { .ant-descriptions-item-label { white-space: nowrap; width: 20px; border: 1px solid black !important; } .ant-descriptions-item-content { white-space: nowrap; border: 1px solid black !important; } } .ant-modal .ant-modal-body{font-size:9px} :deep(.c-table-wrap) { .ant-table-container { table { //padding-bottom: 80px; } .ant-table-cell{ border: 1px solid black !important; padding: 12px 8px; } .ant-table-cell-ellipsis { border-color: black !important; border: 1px; padding: 12px 8px; } } } .order-container { width: 100%; } thead { display: table-header-group; } .order-top, .order-mid, .order-mod, .order-bot, .order-table { page-break-inside: avoid; } td{text-align: center;border: 1px solid #000;} th{ text-align: center;border: 1px solid #000;} .ant-table-row{ page-break-inside: avoid; } td{text-align: center;border: 1px solid #000;} tr {page-break-inside: avoid;} th{ text-align: center;border: 1px solid #000;} table { border-collapse: collapse;} table tr th, table tr td { border: 1px solid #000!important; } #printJS-form table tr td[style*="border-left: none"] { border-left: none !important; } .print-container { transform: scale(0.8); transform-origin: top left; width: 100%; } //@page{size:auto} //.paging{page-break-after: always;} } ` }) } defineExpose({ init, open }) window.onbeforeprint = function () { var links = document.getElementsByTagName("a") for (var i = 0; i < links.length; i++) { links[i].setAttribute("data-href", links[i].href) links[i].removeAttribute("href") } } window.onafterprint = function () { var links = document.getElementsByTagName("a") for (var i = 0; i < links.length; i++) { links[i].href = links[i].getAttribute("data-href") links[i].removeAttribute("data-href") } } </script> <style lang="less" scoped> .order-container { width: 100%; height: 100%; position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; .order-top { width: 100%; display: flex; justify-content: center; position: relative; margin-bottom: 60px; .order-top-title { width: 45%; height: 50px; text-align: center; display: flex; .order-top-logo { img { width: 150px; position: absolute; left: 0; } } .order-top-titles { font-size: 18px; font-weight: bold; width: 100%; margin: 0; } .order-top-vice-title { width: 100%; } } } .order-top-QRCode { display: flex; align-items: center; } .order-mid { width: calc(100%); padding-top: 15px; } .order-mod { width: calc(100%); .order-mod-left { width: 49%; padding: 5px 0; border-radius: 10px; background: #eef0f3; } .order-mod-right { width: 49%; padding: 5px 0; border-radius: 10px; background: #eef0f3; } .order-mod-title { //border: 1px solid #3981ee; padding: 5px; //color: #3981ee; width: 50%; display: flex; align-items: center; justify-content: center; margin: 10px auto; background: #fff; border-radius: 7px; } .order-mod-content { display: flex; align-items: center; width: 100%; margin: 10px auto; .order-mod-content-title { width: 30%; text-align: right; padding: 5px 0; } .order-mod-content-content { flex: 1; white-space: nowrap; } } } .order-bot { width: 100%; margin-top: 10px; } .order-table { //border: 1px solid black !important; // transform: scale(0.7); //width: calc(100% / 0.7); // transform-origin: top center; } } :deep(.ant-descriptions) { .ant-descriptions-item-label { white-space: nowrap; width: 20px; border: 1px solid black !important; } .ant-descriptions-item-content { white-space: nowrap; border: 1px solid black !important; } } :deep(.c-table-wrap) { .ant-table-container { table { //padding-bottom: 80px; } .ant-table-cell { border: 1px solid black !important; padding: 12px 8px; } .ant-table-cell-ellipsis { border-color: black !important; border: 1px; padding: 12px 8px; } } } .order-container { width: 100%; } thead { display: table-header-group; } .order-top, .order-mid, .order-mod, .order-bot, .order-table { page-break-inside: avoid; } .order-mod-title { } td { text-align: center; border: 1px solid #000; } th { text-align: center; border: 1px solid #000; } @media print { a[href]:after { content: none !important; } #footer { display: none; } tr { page-break-inside: avoid; } } .ant-table-row { page-break-inside: avoid; } td { text-align: center; border: 1px solid #000; } tr { page-break-inside: avoid; } th { text-align: center; border: 1px solid #000; } table { border-collapse: collapse; } table tr th, table tr td { border: 1px solid #000 !important; } .ant-descriptions-item-label { white-space: nowrap !important; } .print-container { transform: scale(0.8); transform-origin: top left; width: 100%; } .numbers { font-family: "Arial", sans-serif; /* 或其他不支持自动转换的字体 */ } div { font-family: "Arial", sans-serif; /* 或其他不支持自动转换的字体 */ } .widthClass { width: 1500px !important; } .print-container-div { width: 1500px !important; } </style> 其中 <table class="widthClass" style="font-size: 16px;font-weight: 400;"> <div v-for="(weldItem,index) in item.weldList" :key="item.id" style="width: 100%;"> <tr style="width: 100%;min-height: 30px;" > <td style="width: 5%; text-align: center; vertical-align: middle; display: table-cell;" rowspan="3">{{index+1}}</td> <td style="width: 23%;">{{weldItem.weldNo}}</td> <td style="width: 6%;">BM1*</td> <td style="width: 6%;"></td> <td style="width: 6%;"></td> <td style="width: 6%;"></td> <td style="width: 6%;"></td> <td style="width: 6%;"></td> <td style="width: 6%;"></td> <td style="width: 6%;"></td> <td style="width: 6%;"></td> <td style="width: 6%;"></td> <td style="width: 6%;"></td> <td style="width: 6%;"></td> </tr> <tr style="width: 100%;min-height: 30px;" > <td style="width: 23%;" >{{weldItem.weldNo}}</td> <td style="width: 6%;">Joint</td> <td style="width: 6%;"></td> <td style="width: 6%;"></td> <td style="width: 6%;"></td> <td style="width: 6%;"></td> <td style="width: 6%;"></td> <td style="width: 6%;"></td> <td style="width: 6%;"></td> <td style="width: 6%;"></td> <td style="width: 6%;"></td> <td style="width: 6%;"></td> <td style="width: 6%;"></td> </tr> <tr style="width: 100%;min-height: 30px;" > <td style="width: 23%;">{{weldItem.weldNo}}</td> <td style="width: 6%;">BM2*</td> <td style="width: 6%;"></td> <td style="width: 6%;"></td> <td style="width: 6%;"></td> <td style="width: 6%;"></td> <td style="width: 6%;"></td> <td style="width: 6%;"></td> <td style="width: 6%;"></td> <td style="width: 6%;"></td> <td style="width: 6%;"></td> <td style="width: 6%;"></td> <td style="width: 6%;"></td> </tr> </div> </table>设置宽度 100%没有起作用
最新发布
11-01
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>202502150158郭伟锋</title> <style> div{ margin-left: 2%; margin-right: 2%; } .box1{ width: 100%; height: 23%; border-color: #b20000; border-width: 2px; border-style:solid ; } .box1 p{ border-color: blue; border-width: 2px; border-style:solid ; display: block; width: 15%; float: right; margin-right: 2%; } .box1 img{ margin-left: 2%; width: 15%; height: 20%; } .box2{ margin-top: 2%; width: 100%; height: 60%; } .box2 p{ display: inline; margin-left: 1%; font-weight: bolder; } .img1{ width: 40%; height: 45%; float: left; } .box3{ width: 50%; height: 50%; float: left; } .box3 th{ float: bottom; } </style> </head> <body> <header> <div class="box1"> <img src="images/163logo.gif" > <p >免费邮箱 企业邮箱 VIP邮箱 帮助</p> </div> </header> <section> <div class="box2"> <div> <img src="images/imap.jpg" class="img1"> <br> <th>163/126/yeah三大免费邮箱均默认开放</th> <th>全面支持iPhone/iPad及Android</th> <th>客户端、手机与网页,实现发送、阅读邮件立即同步普通登录手机号登录</th> </div> <div> <form> 用户名 <input type="text" name="username" >@163.com <br> 密码 <input type="password" name="passwd"> <br> 版本 <select id="edition"> <option name="edition" value="默认" selected>默认</option> <option name="edition" value="版本1">版本1</option> </select> </form> </div> </div> </section> <footer> <div> <img src="images/netease_logo.gif "> </div> </footer> </body> </html>为什么我的代码会超出页面需要往右边拉一点,哪里错了
09-30
<template> <c-modal v-model:open="open" title="" @ok="handleOrderOk" width="1600px" :footer="null"> <div style="padding-bottom: 15px"> <a-button key="back" @click="handleCancel" v-if="isFooter">取消</a-button> <a-button key="print" @click="handlePrint">打印</a-button> </div> <div id="printJS-form"> <div v-for="(item, index) in formState" :key="index"> <div class="order-container print-container-div" > <div class="order-top widthClass"> <div class="order-top-title"> <div class="order-top-logo"><img class="logo" src="../../../assets/cimc.png" /></div> <p class="order-top-titles">Piping Welds Positive Material Identification Report</p> </div> </div> <div class="order-top-QRCode widthClass"> <img src="/static/pipe/images/seatrium.png" /> <img src="/static/pipe/images/br.png" /> </div> <div class="printable-area widthClass"> <table class="widthClass"> <tr style="height: 30px"> <td style="width: 50%;"></td> <td style="width: 25%;font-size: 16px;border-left: none !important;">Analysis Data Sheet: </td> <td style="width: 25%;font-size: 16px;border-left: none !important;">BM*:base material</td> </tr> </table> <table class="widthClass" style="font-size: 16px;font-weight: 400;"> <tr style="height: 30px;"> <td style="width: 15%;">Project</td> <td style="width: 20%;"></td> <td style="width: 15%;">Discipline</td> <td style="width: 10%;">Piping</td> <td style="width: 10%;">Insp. Date</td> <td style="width: 30%;"></td> </tr> <tr style="height: 30px;"> <td style="width: 15%;">Dep't</td> <td style="width: 20%;">CIMC QMD - YCRO</td> <td style="width: 15%;">Team</td> <td colspan="3"></td> </tr> </table> <table class="widthClass" style="font-size: 16px;font-weight: 400;"> <tr style="height: 30px;"> <td style="width: 15%;">Inspector</td> <td style="width: 20%;">Zhang Luning</td> <td style="width: 15%;">Inspection Place</td> <td style="width: 20%;">WORKSHOP CENTER</td> <td style="width: 15%;">Material</td> <td style="width: 20%;">S31803</td> </tr> <tr style="height: 30px;"> <td style="width: 15%;">Procedure No</td> <td style="width: 20%;">I-PR-3010.2S-1351-970-YCT-004</td> <td style="width: 15%;">Equip. Name</td> <td style="width: 20%;">FERITSCOPE FMP30</td> <td style="width: 15%;">Serial NO</td> <td style="width: 20%;">100020024</td> </tr> </table> <table class="widthClass" style="font-size: 16px;font-weight: 400;"> <tr style="height: 130px;"> <td style="width: 80%;"><img src="/static/pipe/images/tst.png" /></td> <td style="width: 20%;border-left: none !important;">Acceptance Criteria: a) 30% to 65% for weld metal b) 40% to 65% for HAZ c) 40% to 60% for base metal (including forgings and castings)</td> </tr> </table> <table class="widthClass" style="font-size: 16px;font-weight: 400;"> <tr style="height: 30px;"> <td style="width: 5%;">No</td> <td style="width: 5%;">Point</td> <td style="width: 10%;">Drawing No</td> <td style="width: 10%;">Joint No</td> <td style="width: 10%;">Joint </td> <td style="width: 10%;">HAZ 1/2</td> <td style="width: 10%;">BASE 1/2</td> <td style="width: 10%;">Result</td> <td style="width: 30%;">Result</td> </tr> </table> <table class="widthClass" style="font-size: 16px;font-weight: 400;"> <div v-for="(weldItem,index) in item.weldList" :key="item.id"> <tr style="min-height: 30px;" > <td style="width: 5%; text-align: center; vertical-align: middle; display: table-cell;" rowspan="3" >{{ index }}</td> <td style="width: 5%;">0°</td> <td style="width: 10%;">{{ weldItem.indexNum }}</td> <td style="width: 10%;">{{ weldItem.weldNo }}</td> <td style="width: 10%;">NA </td> <td style="width: 10%;">NA</td> <td style="width: 10%;"></td> <td style="width: 10%;">ACC</td> <td style="width: 30%;"></td> </tr> <tr style="min-height: 30px;"> <!-- <td style="width: 5%;">{{ index }}</td>--> <td style="width: 5%;">90°</td> <td style="width: 10%;">{{ weldItem.indexNum }}</td> <td style="width: 10%;">{{ weldItem.weldNo }}</td> <td style="width: 10%;">NA </td> <td style="width: 10%;">NA</td> <td style="width: 10%;"></td> <td style="width: 10%;">ACC</td> <td style="width: 30%;"></td> </tr> <tr style="min-height: 30px;"> <!-- <td style="width: 5%;">{{ index }}</td>--> <td style="width: 5%;">180°</td> <td style="width: 10%;">{{ weldItem.indexNum }}</td> <td style="width: 10%;">{{ weldItem.weldNo }}</td> <td style="width: 10%;">NA </td> <td style="width: 10%;">NA</td> <td style="width: 10%;"></td> <td style="width: 10%;">ACC</td> <td style="width: 30%;"></td> </tr> </div> </table> <table class="widthClass" style="font-size: 16px;font-weight: 400;min-height: 90px"> <tr style="height: 30px;"> <td style="width: 10%;" rowspan="2">CIMC</td> <td style="width: 10%;">DATE</td> <td style="width: 20%;">SIGNATURE</td> <td style="width: 10%;" rowspan="2">SEATRIUM </td> <td style="width: 10%;">DATE</td> <td style="width: 20%;">SIGNATURE</td> <td style="width: 10%;" rowspan="2">PETROBRAS </td> <td style="width: 10%;">DATE</td> <td style="width: 20%;">SIGNATURE</td> </tr> <tr style="min-height: 80px;"> <td style="width: 10%;"></td> <td style="width: 20%;"></td> <td style="width: 10%;"> </td> <td style="width: 20%;"></td> <td style="width: 10%;"></td> <td style="width: 20%;"></td> </tr> </table> </div> </div> <div style="page-break-after:always"></div> </div> </div> </c-modal> </template> <script setup> import {ref, reactive, onMounted} from "vue" import { print } from "@/utils/print" import * as server from "@/packages/piping/api/cpin"; import {create} from "@/utils/imgtoBase64"; const open = ref(false) const initType = ref() const totalWeight = ref(0) const formState = ref({}) const isFooter = ref(true) const orderTableState = reactive({ datasource: [] }) onMounted(() => { create("/static/mes/images/dataScreen-header-center-bg.png").then((res) => { centerImg.value = res }) }) const handleOrderOk = () => {} const init = (type, data) => { initType.value = type isFooter.value = type === "galv" console.log("data2", data) let printDatas = [] // 使用 Promise.all 等待所有异步操作完成 Promise.all(data.map(async (dataItem) => { try { const res = await server.getOrderList({ page: 0, size: 10000, orderNo: dataItem.orderNo }) let item = res.data.content[0] || {} item.weldList.forEach((weld, index) => { weld.indexNum = index + 1 }) return item } catch (error) { console.error("获取订单列表失败:", error) return {} } })).then(results => { printDatas = results formState.value = printDatas }) } const handleCancel = () => { open.value = false } const handlePrint = () => { print({ // mediaPrint:false, // noPrintSelector:'avoid-this', type: "html", printable: "printJS-form", // type: "raw-html", // printable: "test-dom", // scanStyles: false, // noHeadersAndFooters:true, maxWidth: 1500, targetStyles: ["*"], scanStyles: false, style: ` table{font-size:3px} td{font-size:10px !important} .print-container-div{ width: 1100px !important; } .widthClass{ width: 1000px; font-size:1px } .ant-descriptions-view >table{ width:100%!important; font-size:1px; } @media print { a[href]:after { content: none !important; } #footer { display: none; } } .imgInline{ display: flex;} .order-top-QRCode{float:right} .order-top-title { width: 100%; height: 50px; text-align: center; display: flex; padding-top:15px } .order-top-logo { img { margin-top:10px; width: 150px; position: absolute; left: 0; } } .order-top-titles { font-size: 25px; font-weight: bold; width: 100%; margin: 0; align:center; text-align:center; padding-top:15px; } .order-top-vice-title { width: 100%; } .logo{width:150px;height:20px} .paging{page-break-after: aways;} .order-container { width: 100%; height: 100%; position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; .order-top { width: 100%; display: flex; justify-content: center; position: relative; margin-bottom: 38px; .order-top-title { width: 45%; height: 50px; text-align: center; display: flex; .order-top-logo { img { width: 150px; position: absolute; left: 0; } } .order-top-titles { font-size: 25px; font-weight: bold; width: 100%; margin: 0; } .order-top-vice-title { width: 100%; } } } .order-top-QRCode { position: absolute; right: 0; top: 0; display: flex; align-items: center; justify-content: flex-end; } .order-mid { width: calc(100%); padding-top: 15px; } .order-mod { width: calc(100% ); .order-mod-left{ width: 49%; padding: 5px 0; border-radius: 10px; background: #eef0f3; } .order-mod-right { width: 49%; padding: 5px 0; border-radius: 10px; background: #eef0f3; } .order-mod-title { //border: 1px solid #3981ee; padding: 5px; //color: #3981ee; width: 50%; display: flex; align-items: center; justify-content: center; margin: 10px auto; background: #fff; border-radius: 7px; } .order-mod-content { display: flex; align-items: center; width: 100%; margin: 10px auto; .order-mod-content-title { width: 30%; text-align: right; padding: 5px 0; } .order-mod-content-content { flex: 1; white-space: nowrap; } } } .order-bot { width: 100%; margin-top: 10px; } .order-table { //border: 1px solid black !important; // transform: scale(0.7); //width: calc(100% / 0.7); // transform-origin: top center; } } :deep(.ant-descriptions) { .ant-descriptions-item-label { white-space: nowrap; width: 20px; border: 1px solid black !important; } .ant-descriptions-item-content { white-space: nowrap; border: 1px solid black !important; } } .ant-modal .ant-modal-body{font-size:9px} :deep(.c-table-wrap) { .ant-table-container { table { //padding-bottom: 80px; } .ant-table-cell{ border: 1px solid black !important; padding: 12px 8px; } .ant-table-cell-ellipsis { border-color: black !important; border: 1px; padding: 12px 8px; } } } .order-container { width: 100%; } thead { display: table-header-group; } .order-top, .order-mid, .order-mod, .order-bot, .order-table { page-break-inside: avoid; } td{text-align: center;border: 1px solid #000;} th{ text-align: center;border: 1px solid #000;} .ant-table-row{ page-break-inside: avoid; } td{text-align: center;border: 1px solid #000;} tr {page-break-inside: avoid;} th{ text-align: center;border: 1px solid #000;} table { border-collapse: collapse;} table tr th, table tr td { border: 1px solid #000!important; } #printJS-form table tr td[style*="border-left: none"] { border-left: none !important; } .print-container { transform: scale(0.8); transform-origin: top left; width: 100%; } //@page{size:auto} //.paging{page-break-after: always;} } ` }) } defineExpose({ init, open }) window.onbeforeprint = function () { var links = document.getElementsByTagName("a") for (var i = 0; i < links.length; i++) { links[i].setAttribute("data-href", links[i].href) links[i].removeAttribute("href") } } window.onafterprint = function () { var links = document.getElementsByTagName("a") for (var i = 0; i < links.length; i++) { links[i].href = links[i].getAttribute("data-href") links[i].removeAttribute("data-href") } } </script> <style lang="less" scoped> .order-container { width: 100%; height: 100%; position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; .order-top { width: 100%; display: flex; justify-content: center; position: relative; margin-bottom: 38px; .order-top-title { width: 45%; height: 50px; text-align: center; display: flex; .order-top-logo { img { width: 150px; position: absolute; left: 0; } } .order-top-titles { font-size: 25px; font-weight: bold; width: 100%; margin: 0; } .order-top-vice-title { width: 100%; } } } .order-top-QRCode { position: absolute; right: 0; top: 0; display: flex; align-items: center; justify-content: flex-end; } .order-mid { width: calc(100%); padding-top: 15px; } .order-mod { width: calc(100%); .order-mod-left { width: 49%; padding: 5px 0; border-radius: 10px; background: #eef0f3; } .order-mod-right { width: 49%; padding: 5px 0; border-radius: 10px; background: #eef0f3; } .order-mod-title { //border: 1px solid #3981ee; padding: 5px; //color: #3981ee; width: 50%; display: flex; align-items: center; justify-content: center; margin: 10px auto; background: #fff; border-radius: 7px; } .order-mod-content { display: flex; align-items: center; width: 100%; margin: 10px auto; .order-mod-content-title { width: 30%; text-align: right; padding: 5px 0; } .order-mod-content-content { flex: 1; white-space: nowrap; } } } .order-bot { width: 100%; margin-top: 10px; } .order-table { //border: 1px solid black !important; // transform: scale(0.7); //width: calc(100% / 0.7); // transform-origin: top center; } } :deep(.ant-descriptions) { .ant-descriptions-item-label { white-space: nowrap; width: 20px; border: 1px solid black !important; } .ant-descriptions-item-content { white-space: nowrap; border: 1px solid black !important; } } :deep(.c-table-wrap) { .ant-table-container { table { //padding-bottom: 80px; } .ant-table-cell { border: 1px solid black !important; padding: 12px 8px; } .ant-table-cell-ellipsis { border-color: black !important; border: 1px; padding: 12px 8px; } } } .order-container { width: 100%; } thead { display: table-header-group; } .order-top, .order-mid, .order-mod, .order-bot, .order-table { page-break-inside: avoid; } .order-mod-title { } td { text-align: center; border: 1px solid #000; } th { text-align: center; border: 1px solid #000; } @media print { a[href]:after { content: none !important; } #footer { display: none; } tr { page-break-inside: avoid; } } .ant-table-row { page-break-inside: avoid; } td { text-align: center; border: 1px solid #000; } tr { page-break-inside: avoid; } th { text-align: center; border: 1px solid #000; } table { border-collapse: collapse; } table tr th, table tr td { border: 1px solid #000 !important; } .ant-descriptions-item-label { white-space: nowrap !important; } .print-container { transform: scale(0.8); transform-origin: top left; width: 100%; } .numbers { font-family: "Arial", sans-serif; /* 或其他不支持自动转换的字体 */ } div { font-family: "Arial", sans-serif; /* 或其他不支持自动转换的字体 */ } .widthClass { width: 1500px !important; } .print-container-div { width: 1500px !important; } </style> 这里<td style="width: 25%;font-size: 16px;border-left: none !important;">Analysis Data Sheet: </td> 为什么border-left: none !important;没起作用
11-01
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值