Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/70.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python IMG()中的Web2Py CSS样式_Python_Html_Css_Web2py - Fatal编程技术网

Python IMG()中的Web2Py CSS样式

Python IMG()中的Web2Py CSS样式,python,html,css,web2py,Python,Html,Css,Web2py,我试图通过调用Web2Py中的{{{=IMG()}}来获取设置CSS的基本语法。我尝试了以下方法: <style>img.bottom { vertical-align: text-bottom; } </style> <body> {{=IMG(_src=URL('static',args='images/golem.jpg', _style='img.bottom'),_alt="golem"}} </body> img.bo

我试图通过调用Web2Py中的
{{{=IMG()}}
来获取设置CSS的基本语法。我尝试了以下方法:

 <style>img.bottom { vertical-align: text-bottom; } </style>
 <body>
     {{=IMG(_src=URL('static',args='images/golem.jpg', _style='img.bottom'),_alt="golem"}}
 </body>
img.bottom{垂直对齐:文本底部;}
{{=IMG({u src=URL('static',args='images/golem.jpg',{u style='IMG.bottom'),{u alt=“golem”}}
失败


{{=IMG({u src=URL('static',args='images/golem.jpg',style={'CODE':'vertical-align:text-bottom;'}),{u alt=“golem”)}
也失败了

 <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.bottom{垂直对齐:文本底部;}
{{=IMG({u src=URL('static',args='images/golem.jpg'),{u style='bottom',{u alt=“golem”}}
也失败了

 <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.bottom{垂直对齐:文本底部;}
{{=IMG({u src=URL('static',args='images/golem.jpg'),{u class='bottom',{u alt=“golem”}}
也失败了

 <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>
我觉得我必须接近,但我在文档中找不到style to
IMG()
的参数,而且我似乎无法覆盖当前的(非)样式

虽然这确实有效,但我不喜欢它。它很难看,我不接受它作为一个答案。我只是想提供一个解决办法,以防明年有人发现这个问题(没有答案)

 <style> img.bottom { vertical-align: text-bottom; } </style>
 <body>
     <img src={{=URL('static','images',args='golem.jpg')}} alt="golem"class=bottom>
 </body>
img.bottom{垂直对齐:文本底部;}
您可以执行以下操作:

{{=IMG(_src=URL('static', 'images', args='golem.jpg'), _alt='golem',
       _style='vertical-align: text-bottom')}}
或:

img.bottom{垂直对齐:文本底部;}
{{=IMG({u src=URL('static','images',args='golem.jpg'),{u alt='golem',
_class='bottom')}
如文件所述:

以下划线开头的命名参数被解释为HTML标记属性(不带下划线)


尽管这本书没有具体说明如何在
IMG
中使用“\u-style”或“\u-class”参数,但有许多“\u-class”参数的示例以及其他HTML帮助程序中使用的其他HTML属性。

您(像往常一样)是的。我知道我试过这个。我一定是打错了。嗨。有没有一个选项可以从几个图像中随机选择一个图像?如果你问
IMG()
helper是否包含这样一个选项,没有(对于一个简单的HTML助手来说,这似乎是一个罕见的用例),但这只是Python代码,所以编写自己的代码来选择随机图像应该很简单。接近:.jpg“>接近:.jpg”>有没有办法从static/images文件夹中随机选择一个图像?@wakamdr你要么在javascript中维护一个硬编码列表/字典,要么在服务器端查询python/php/中的目录,不管你的页面运行在什么地方。这本身就是一个很好的问题(如果还没有回答,我没有搜索)