当前位置:首页 > CSS

html css 制作单据

2026-02-12 13:16:58CSS

HTML和CSS制作单据的步骤

单据结构设计
使用HTML构建单据的基本框架,包含表头、表格主体和表尾。表头通常包含单据标题、编号和日期;表格主体用于展示明细数据;表尾包含合计金额和备注信息。

<div class="invoice">
  <div class="header">
    <h1>销售单据</h1>
    <p>编号: INV-2023-001</p>
    <p>日期: 2023-10-01</p>
  </div>

  <table class="details">
    <thead>
      <tr>
        <th>序号</th>
        <th>商品名称</th>
        <th>数量</th>
        <th>单价</th>
        <th>金额</th>
      </tr>
    </thead>
    <tbody>
      <tr>
        <td>1</td>
        <td>商品A</td>
        <td>2</td>
        <td>100</td>
        <td>200</td>
      </tr>
    </tbody>
  </table>

  <div class="footer">
    <p>合计: 200元</p>
    <p>备注: 现金支付</p>
  </div>
</div>

样式设计
通过CSS为单据添加样式,包括边框、字体、颜色和对齐方式。单据通常采用固定宽度和清晰的边框以增强可读性。

.invoice {
  width: 800px;
  margin: 0 auto;
  border: 1px solid #000;
  padding: 20px;
  font-family: Arial, sans-serif;
}

.header {
  text-align: center;
  margin-bottom: 20px;
}

.details {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 20px;
}

.details th, .details td {
  border: 1px solid #000;
  padding: 8px;
  text-align: center;
}

.footer {
  text-align: right;
}

响应式设计
确保单据在移动设备上也能正常显示,通过媒体查询调整布局和字体大小。

@media (max-width: 600px) {
  .invoice {
    width: 100%;
    padding: 10px;
  }

  .details th, .details td {
    padding: 4px;
    font-size: 12px;
  }
}

打印优化
为单据添加打印样式,确保打印时背景色和边框正常显示。

html css 制作单据

@media print {
  .invoice {
    width: 100%;
    border: none;
  }

  .details {
    page-break-inside: avoid;
  }
}

通过以上步骤,可以制作一个结构清晰、样式美观且支持响应式和打印的单据。

标签: 单据html
分享给朋友:

相关文章

react如何渲染html

react如何渲染html

渲染HTML字符串的方法 在React中渲染HTML字符串需要使用dangerouslySetInnerHTML属性。该属性允许直接插入HTML内容,但需谨慎使用以避免XSS攻击。 function…

react如何解析html

react如何解析html

解析 HTML 的方法 在 React 中解析 HTML 字符串并渲染为 DOM 元素时,需要注意安全性和正确性。以下是几种常见的方法: 使用 dangerouslySetInnerHTML Re…

html css js制作

html css js制作

HTML、CSS 和 JavaScript 制作网页的基本方法 创建 HTML 结构 HTML 是网页的骨架,负责定义内容和结构。使用语义化标签如 <header>、<nav>…

jquery追加html

jquery追加html

使用 jQuery 追加 HTML 内容的方法 jQuery 提供了多种方法来动态追加 HTML 内容到 DOM 元素中。以下是几种常用的方法: append() 将内容插入到匹配元素的内部末尾处。…

react如何渲染html

react如何渲染html

渲染 HTML 字符串的方法 在 React 中直接渲染 HTML 字符串需要使用 dangerouslySetInnerHTML 属性。该属性允许插入未经转义的 HTML 内容,但需谨慎使用以避免…