html - 横向打印网页

标签 html css printing

我在需要以横向模式打印的网页上生成报告。

这几天我一直在搜索这个,在网上找到了很多答案。基本上需要一个简单的样式:

@page {
    size: landscape;
    margin: 0.5cm 0.5cm 0.5cm 0.5cm;
}

但这似乎对我不起作用。

有人可以帮忙吗?

谢谢。

最佳答案

检查此方法。我在 Chrome 和 Mozilla Firefox 中对此进行了测试。您可以使用您的内容和样式进一步改进它。这是一个可以打印的示例页面。将其另存为 Html 页面尝试更多类似这些 您可以引用更多from here

<html>

<head>
  <style type="text/css">
    h3 {
      text-align: center;
    }
  
    .output {
      height;
      8.5in;
      width: 11in;
      border: 1px solid red;
      position: absolute;
      top: 0px;
      left: 0px;
    }
    @media print {
      .output {
        -ms-transform: rotate(270deg);
        /* IE 9 */
        -webkit-transform: rotate(270deg);
        /* Chrome, Safari, Opera */
        transform: rotate(270deg);
        top: 1.5in;
        left: -1in;
      }
    }
  </style>

</head>

<body>
  <div class="output">
    Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.

Why do we use it?
It is a long established fact that a reader will be distracted by the readable content of a page when looking at its layout. The point of using Lorem Ipsum is that it has a more-or-less normal distribution of letters, as opposed to using 'Content here, content here', making it look like readable English. Many desktop publishing packages and web page editors now use Lorem Ipsum as their default model text, and a search for 'lorem ipsum' will uncover many web sites still in their infancy. Various versions have evolved over the years, sometimes by accident, sometimes on purpose (injected humour and the like).


Where does it come from?
Contrary to popular belief, Lorem Ipsum is not simply random text. It has roots in a piece of classical Latin literature from 45 BC, making it over 2000 years old. Richard McClintock, a Latin professor at Hampden-Sydney College in Virginia, looked up one of the more obscure Latin words, consectetur, from a Lorem Ipsum passage, and going through the cites of the word in classical literature, discovered the undoubtable source. Lorem Ipsum comes from sections 1.10.32 and 1.10.33 of "de Finibus Bonorum et Malorum" (The Extremes of Good and Evil) by Cicero, written in 45 BC. This book is a treatise on the theory of ethics, very popular during the Renaissance. The first line of Lorem Ipsum, "Lorem ipsum dolor sit amet..", comes from a line in section 1.10.32.
  </div>
</body>

</html>

关于html - 横向打印网页,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39659168/

相关文章:

javascript - 在页面加载时隐藏模态元素的更好方法

javascript - 在本地运行复杂的网络应用程序

css - 输入 [type=select] 对我不起作用

html - 为什么标签 P 包含 DIV 时弹出 DIV?

android - 在 android 中的 Star TSP100 打印机上创建光栅收据

c - 结构变量打印

c - 尝试从数组中打印出网格,但实际上没有显示任何内容

javascript - 当脚本类型设置为 "application/javascript"时,AJAX 的 JS 组件不起作用

javascript - 在 Javascript 中调用 CSS

javascript - 提交 JQuery 后隐藏表单