我正在尝试获取设置 CSS 的基本语法 <style>
使用调用 {{=IMG()}}
在 Web2Py 中。我尝试了以下方法:
<style>img.bottom { vertical-align: text-bottom; } </style>
<body>
{{=IMG(_src=URL('static',args='images/golem.jpg', _style='img.bottom'),_alt="golem"}}
</body>
失败
<body>
{{=IMG(_src=URL('static',args='images/golem.jpg', styles={'CODE':'vertical-align: text-bottom;'}), _alt="golem")}}
<body>
同样失败
<style>img.bottom { vertical-align: text-bottom; } </style>
<body>
{{=IMG(_src=URL('static',args='images/golem.jpg'), _style='bottom',_alt="golem"}}
</body>
同样失败
<style>img.bottom { vertical-align: text-bottom; } </style>
<body>
{{=IMG(_src=URL('static',args='images/golem.jpg'), _class='bottom',_alt="golem"}}
</body>
同样失败
我觉得我一定很接近,但我找不到 IMG()
风格的论据在文档中,我似乎无法覆盖存在的(非)样式。
Just in case anyone wants to see the Web2Py docs where the answer is not
最佳答案
你可以这样做:
{{=IMG(_src=URL('static', 'images', args='golem.jpg'), _alt='golem',
_style='vertical-align: text-bottom')}}
或:
<style>img.bottom {vertical-align: text-bottom;}</style>
{{=IMG(_src=URL('static', 'images', args='golem.jpg'), _alt='golem',
_class='bottom')}}
如前所述here在文档中:
Named arguments that start with an underscore are interpreted as HTML tag attributes (without the underscore).
虽然这本书没有具体展示在 IMG
中使用“_style”或“_class”参数的示例,但有许多“_class”参数以及其他 HTML 属性的示例与其他 HTML 助手一起使用。
关于python - IMG() 中的 Web2Py CSS 样式,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25575204/