使用属性mixin jade的内联样式宽度

问题描述 投票:0回答:1

我正在尝试使用jade mixins按照link中提供的答案进行内联样式,但它不会像它所使用的那样工作。

我正在使用这种玉:

mixin centerImg(margin,imgWidth,imgWidthpx,imgId)
table(border="0", cellpadding="0", cellspacing="0", width="640")
    tr
        td(width=margin)
        td(width=imgWidth)
            a.antiHand(href='#', style='cursor: none !important; pointer-events: none; border-style: none; border: none; border-color: transparent;')
                img(alt="", style="width:#{imgWidth};max-width:#{imgWidthpx};display:block;margin:0")(width=imgWidth)(src=imgId)
        td(width=margin)

+centerImg(200,240,"240px",'https://media.giphy.com/media/SzzNGHZWHCBqw/giphy.gif')

这就是我得到的:

<table border="0" cellpadding="0" cellspacing="0" width="640">
          <tr>
            <td width="200"></td>
            <td width="240"><a class="antiHand" href="#" style="cursor: none !important; pointer-events: none; border-style: none; border: none; border-color: transparent;"><img alt="" style="width:#{imgWidth};max-width:#{imgWidthpx};display:block;margin:0" width="240" src="https://media.giphy.com/media/SzzNGHZWHCBqw/giphy.gif"/></a></td>
            <td width="200"></td>
          </tr>
        </table>

有任何想法吗?

email pug html-email mixins
1个回答
0
投票

这段代码:

style="width:#{imgWidth};max-width:#{imgWidthpx};display:block;margin:0"

应该改变这样:

style=`width:${imgWidth};max-width:${imgWidthpx};display:block;margin:0`

我觉得这个有效!

© www.soinside.com 2019 - 2024. All rights reserved.