Inline style via attribute mixin jade

非 Y 不嫁゛ 提交于 2019-12-12 01:14:26

问题


Is there any way of declaring a CSS width inline via a mixin attribute in Jade? An example of what I have tried is below...

mixin button(buttonLink, buttonText, buttonWidth)
 +link(buttonLink)(style='width:"buttonWidth"')
  font(style='color: #ffffff; text-decoration: none;') 
   =buttonText

Thanks.


回答1:


Yeah, it's possible ;)

   mixin button(buttonLink, buttonText, buttonWidth)
     +link(buttonLink)(style="width:#{buttonWidth}")
       font(style='color: #ffffff; text-decoration: none;') 
         =buttonText

    mixin link(buttonLink)
      a(src=buttonLink, style=attributes.style)
        block

    +button("http://github.com", "github", 10)

BTW: don't use <font>
https://developer.mozilla.org/de/docs/Web/HTML/Element/font




回答2:


a little late, but this works as well!

mixin button(buttonLink, buttonText, buttonWidth)
  +link(buttonLink)(style='width:"'+buttonWidth+'"')
    font(style='color: #ffffff; text-decoration: none;') 
      =buttonText


来源:https://stackoverflow.com/questions/25851294/inline-style-via-attribute-mixin-jade

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!