gpt4 book ai didi

html - 打印时如何使带有内容的单个div填满整个页面

转载 作者:行者123 更新时间:2023-11-28 19:26:37 25 4
gpt4 key购买 nike

我有一个需要能够打印标签的 aurela 应用程序。在带有表单的页面上,有一个隐藏的 div,其中包含标签的布局。我只想打印隐藏的 div,我希望它被拉伸(stretch)(包含内容)以在横向页面中达到完整大小。目前它只填充页面的一个小 Angular 。

JSFiddle Label

这是我尝试让它工作的 CSS。奇怪的是对@page 的更改没有任何作用。我尝试了不同的页面大小,但没有任何影响 div,它仍然位于一个 Angular 落。

    @media print {
header, footer, .print-hidden {
visibility: hidden;
}

@page {
size: auto;
margin: 0mm;
}

html, body {
height: 100%;
width: 100%;
}

.print-show{
display: block;

position: absolute;

width: 100vw;
height: 100vh;
top:0;
bottom:0;
}
}

这是标签的 aurelia 模板

<template bindable="firstname, lastname, company, inviter, uniquecode">
<div class="label-container">
<div class="row justify-content-start mx-0 px-1 pt-1">
<div class="text-center">
<img class="label-logo" src="image.png">
<div class="visitor-logo">VISITOR</div>
</div>
</div>
<div class="flex-row text-center label-name">
<div>${firstname}</div>
<div>${lastname}</div>
</div>
<div class="text-center label-company">
${company}
</div>
<div class="row justify-content-between mx-0 px-1">
<div>
<div class="label-guestof">Guest of</div>
<div class="label-inviter">${inviter}</div>
</div>
<span>${uniquecode}</span>
</div>
</div>

这里是标签的自定义 css 类:

    .label-container{
width: 350px;
height: 188px;
}

.visitor-logo{
font-weight: normal;
font-size: 15px;
color: #505659;
}

.label-name{
font-weight: 600;
font-size: 28px;
color: #2B3033;
}

.label-company{
font-weight: normal;
font-size: 12px;
color: #737B80;
}

.label-guestof{
font-weight: normal;
font-size: 10px;
color: #737B80;
}

.label-inviter{
font-weight: 600;
font-size: 12px;
color: #505659;
}

.label-logo{
height: 28px;
width: 60px;
}

最佳答案

我稍微重新设计了它的样式并添加了背景颜色以便更好地检查。我希望这就是你要找的。如果不是的话,这样做会很有趣 :P。

<!--index.html-->
<div class="label-container">
<div class="label-container__header mx-0 px-1 pt-1">
<div class="text-center">
<img class="label-logo" src="image.png">
<div class="visitor-logo">VISITOR</div>
</div>
</div>
<div class="label-container__names label-name">
<div>${firstname}</div>
<div>${lastname}</div>
</div>
<div class="label-container__company label-company">
${company}
</div>
<div class="label-container__footer justify-content-between mx-0 px-1">
<div>
<div class="label-guestof">Guest of</div>
<div class="label-inviter">${inviter}</div>
</div>
<span>${uniquecode}</span>
</div>
</div>

// style.css
html, body {
height: 100%;
width: 100%;
}

.label-container {
width: auto;
height: 100%;
background-color: #aaa;

display: flex;
flex-direction: column;
justify-content: space-between;
}

.label-container__header {
display: flex;
justify-content: flex-start;
align-items: flex-start;
}

.label-container__names {
display: flex;
flex-direction: column;
align-items: center;
}

.label-container__company {
display: flex;
justify-content: center;
}

.label-container__footer {
display: flex;
justify-content: flex-end;
}

.visitor-logo{
font-weight: normal;
font-size: 15px;
color: #505659;
}

.label-name{
font-weight: 600;
font-size: 28px;
color: #2B3033;
}

.label-company{
font-weight: normal;
font-size: 12px;
color: #737B80;
}

.label-guestof{
font-weight: normal;
font-size: 10px;
color: #737B80;
}

.label-inviter{
font-weight: 600;
font-size: 12px;
color: #505659;
}

.label-logo{
height: 28px;
width: 60px;
}

关于html - 打印时如何使带有内容的单个div填满整个页面,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56022763/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com