python - IMG() 中的 Web2Py CSS 样式

标签 python html css web2py

我正在尝试获取设置 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/

相关文章:

javascript - 带有图像的单选按钮

python - 无限运行服务器端python脚本?

jQuery点击改变背景颜色

javascript - 如何使用 JavaScript 读取 post 请求参数

javascript - 单击下拉菜单显示叠加层

html - Css 响应图像问题

python - 计算 NetworkX 多重图中给定路径的权重总和

python - Pandas - 合并两个具有相同列名的 DataFrame

python - 从 Image Generator 绘制图像

html - 使用 Material ui svg 图标作为背景图片