lesscss 打印样式

发布于 2024-12-21 14:50:00 字数 390 浏览 5 评论 0原文

我想使用 lesscss 进行打印, 但浏览器似乎无法识别@media print

因为我不想嵌入

<link rel="stylesheet/css" type="text/css" href="themes/css/print.css" media="print">

到页面中。

有人可以帮忙解决这个问题吗? lesscss源代码地址在这里

https://github .com

谢谢

I want using lesscss for print,
but it seems, the browser don't recongize the @media print,

since I don't want embbed

<link rel="stylesheet/css" type="text/css" href="themes/css/print.css" media="print">

into page.

can anyone help on this issue? lesscss sourse code address is here

https://github.com

thanks

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

面如桃花 2024-12-28 14:50:00
<link rel="stylesheet/less" href="http://worldMaps.org/maps/styles/growth.less" media="all">

重要的部分是 media="all",否则它将无法正确解析链接的 less 文件中的 @media print {.no-print {display:none;}} 。

<link rel="stylesheet/less" href="http://worldMaps.org/maps/styles/growth.less" media="all">

The important part is the media="all", otherwise it will not correctly parse your @media print {.no-print {display:none;}} inside your linked less file.

小ぇ时光︴ 2024-12-28 14:50:00

如果您的问题是如何嵌入较少样式的媒体打印:链接标记中的媒体属性对我有用。

<link rel="stylesheet/less" type="text/css" href="print.less" media="print">

media="print" 是必不可少的,因为默认情况下 less 会将编译样式插入为 media="screen"

If your question is how to embed less-styles for media print: the media attribute within the link tag worked for me.

<link rel="stylesheet/less" type="text/css" href="print.less" media="print">

The media="print" is essential as less by default inserts compiled styles as media="screen".

小忆控 2024-12-28 14:50:00

当我使用 .less 时,用于显示打印样式的 Web 开发人员工具选项无法为我呈现。

我的解决方案,虽然根据浏览器的不同可能无法 100% 正确呈现,但在样式表,以便在页面加载时呈现打印样式。

如果出现以下情况,我不建议使用此解决方案:

  • 您需要跟踪屏幕和打印样式
  • 您需要精确的测量

如果出现以下情况,我建议使用此解决方案:

  • 您不想持续每次后返回打印预览
    调整
  • 你愿意牺牲以上内容来测试内容安排和样式结构

While I was using .less, the web developer tool option for displaying print styles wasn't rendering for me.

My solution, although may not render 100% correctly depending on the browser, is to switch the @media print and @media screen properties in the style sheet so that on page load, the print styles are rendered.

I don't suggest this solution if:

  • You need to trace both screen and print styles
  • You need precise measurements

I do suggest this solution if:

  • You don't want to continually go back to print preview after every
    adjustment
  • You are willing to sacrifice the above in order to test content arrangement and styling structure
旧人 2024-12-28 14:50:00

如果您使用 lesscss,请在“less”文件中使用 @media 属性。

像这样:

@media: mobile;

.mixin (@a) when (@media = mobile) { ... }
.mixin (@a) when (@media = desktop) { ... }

并正常导入文件:

<link rel="stylesheet/css" type="text/css" href="themes/css/print.less">

http://lesscss.org/#-pattern -匹配和保护表达式

If you are using lesscss, use @media property into "less" file.

Like this:

@media: mobile;

.mixin (@a) when (@media = mobile) { ... }
.mixin (@a) when (@media = desktop) { ... }

And import file normaly:

<link rel="stylesheet/css" type="text/css" href="themes/css/print.less">

http://lesscss.org/#-pattern-matching-and-guard-expressions

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文