【问题标题】:Creating a rounded image with limited standard CSS properties?创建具有有限标准 CSS 属性的圆形图像?
【发布时间】:2020-03-11 17:58:02
【问题描述】:

是否可以使用一组有限的 CSS 属性创建圆形图像?我正在使用 python 的xhtml2pdf,它只支持一些 CSS 属性。

唯一可用的 CSS 属性是:

background-color
border-bottom-color, border-bottom-style, border-bottom-width
border-left-color, border-left-style, border-left-width
border-right-color, border-right-style, border-right-width
border-top-color, border-top-style, border-top-width
colordisplay
font-family, font-size, font-style, font-weight
height
line-height, list-style-type
margin-bottom, margin-left, margin-right, margin-top
padding-bottom, padding-left, padding-right, padding-top
page-break-after, page-break-before
size
text-align, text-decoration, text-indent
vertical-align
white-space
width
zoom

【问题讨论】:

  • 不,不可能。您可以使用任何其他库创建图像本身并将生成的图像插入到 pdf 中。
  • 谢谢伙计。我将使用 PIL 使图像变圆。您可以将此作为答案发布,我会接受。
  • 没有使用img 进行测试,但this question 是关于没有边框半径的圆形边框,可能会对您有所帮助。

标签: css xhtml2pdf


【解决方案1】:

遗憾的是,这对于这组有限的 CSS 属性是不可能的。

但是您可以使用另一个库来修改现有图像并创建带有圆形边框的图像版本(并为其添加一些过滤器,基本上可以做任何您想做的事情)

编辑:由于评论中提到了 PIL:PIL round edges and add border(类似这样,另请参阅链接的问题/答案)

那你就在 pdf 中使用这张图片,没有人会注意到有什么不同。

【讨论】:

    猜你喜欢
    • 2016-05-07
    • 2019-10-17
    • 2012-12-13
    • 2014-05-09
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-08-29
    • 2016-01-20
    相关资源
    最近更新 更多