【问题标题】:Any Alternative fix for printing a webpage when designed with vmin/vmax/vw/vh-font-sized texts使用 vmin/vmax/vw/vh-font-sized 文本设计时打印网页的任何替代修复
【发布时间】:2016-01-21 07:44:39
【问题描述】:

所以我正在研究流体响应式设计,并且网站上的文本大小基于 %. 刚刚意识到,如果我尝试打印(cmd+p)网站设计会在 chrome 上中断。 看起来像一个非常古老且已知的问题,并且无法在网上找到一个黑客来完成这项工作? 您能就此提出一些建议吗?

这里提到的问题:https://code.google.com/p/chromium/issues/detail?id=382313 这是您可以尝试放在本地 html 页面上并尝试在 chrome 上打印的 html:

<!DOCTYPE html>
<html>
<head>
    <title></title>
    <style>
        .vmin {
    font-size: 10vmin;
}

.px {
    font-size: 20px;
}

.vw {
    font-size: 10vw;
}

.vh {
    font-size: 10vh;
}

.box {
    width: 10vw;
    height: 10vh;
    border: 1px solid #000;
}
    </style>
</head>
<body>
<div class="vmin">
    using vmin - font-size: 10vmin;
</div>
<div class="px">
    using px - font-size: 20px;
</div>
<div class="vw">
    using vw - font-size: 10vw;
</div>
<div class="vh">
    using vh - font-size: 10vh;
</div>
<div class="box">
    inside box - box size: 10vw x 10vh;
</div>
</body>
</html>

如果有一种方法可以在调用打印时传递硬编码的视图大小,那也是一件好事?

【问题讨论】:

    标签: html css google-chrome viewport-units


    【解决方案1】:
    <style media="screen">
    .vmin {
        font-size: 10vmin;
    }
    
    .px {
        font-size: 20px;
    }
    
    .vw {
        font-size: 10vw;
    }
    
    .vh {
        font-size: 10vh;
    }
    
    .box {
        width: 10vw;
        height: 10vh;
        border: 1px solid #000;
    }
    </style>
    
    <style media="print">
            /* Here be CSS applied exclusively when the page is printed */
    </style>
    

    http://htmldog.com/references/html/tags/style/

    【讨论】:

      猜你喜欢
      • 2014-12-28
      • 2015-07-22
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-01-23
      • 1970-01-01
      • 2013-02-07
      • 2020-12-21
      相关资源
      最近更新 更多