带有打嗝的内联样式 [英] Inline styling with hiccup

查看:33
本文介绍了带有打嗝的内联样式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个使用 clojure hiccup 生成的 html 文档.当我将文件作为电子邮件的附件发送时,css 会被删除.css 是外部的,并在文件的头部被引用,如下所示:

I have an html document that I generate with clojure hiccup. When I send the file as an attachment to an email, the css gets stripped out. The css is external and being referenced in the head of the file like below:

[:head
  [:title "My Title"]
   (include-css "css/mycss.css")]

我听说邮件服务器删除了所有外部 css,因此它不会干扰他们的.我能够找到的一个解决方案是进行内联样式.例如,如果我有以下 html,我如何对其执行内联样式.

I heard mail servers strip out all external css so it does not interfere with theirs. One solution I was able to fin was to do an inline styling. For example if I have the below html, how do I perform inline styling on it.

[:thead
   [:tr [:th "First column"] [:th "Second column"] [:th "Third column"]]]

另外,如果我想做的事情有更好的答案,请随时提出建议.谢谢!

Additionally, feel free to suggest if there is a better answer to what I want to do. Thanks!

推荐答案

hiccup 支持使用 {} 语法开箱即用的属性,因此您可以简单地使用它来设置元素的样式属性很容易,例如, [:p {:style "color:#E0E0E0"} "My Paragraph"] 会将颜色放在段落上.但我想在您的情况下,使用 style 元素将一般样式定义放在 head 元素中可能更方便.hiccup 支持 :style,正如人们所期望的那样,例如

hiccup supports attributes right out of the box with the {} syntax, so you could simply use this for settings style attributes on elements easily, e.g., [:p {:style "color:#E0E0E0"} "My paragraph"] will put the color on the paragraph. But I guess in your case, it might be more convenient to put the general style definitions in the head element, using the style element. hiccup supports :style for this as one would expect, e.g.

[:head [:title "My title"]
       [:style "body { padding-top: 60px; }"]].

这篇关于带有打嗝的内联样式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆