Html 在表格行中放置图像
我在html/css方面很弱 我有从数据库调用的动态图像数。一次一行显示3个图像。 这是我的表格html/css:Html 在表格行中放置图像,html,css,Html,Css,我在html/css方面很弱 我有从数据库调用的动态图像数。一次一行显示3个图像。 这是我的表格html/css: <style> table { border-collapse: collapse; table-layout: fixed; max-width: 100% } figure { display: block; margin-before: 1em;
<style>
table {
border-collapse: collapse;
table-layout: fixed;
max-width: 100%
}
figure {
display: block;
margin-before: 1em;
margin-after: 1em;
margin-start: 40px;
margin-end: 40px;
}
figure img {
padding: 5px;
background: #fff;
}
figcaption {
padding: 5px;
font-family: 'Cherry Swash', cursive;
font-size: 1em;
font-weight: 700;
border: none;
background: transparent;
word-wrap:normal;
text-align: center;
}
a {
text-decoration:none;
}
</style>
<table>
<tr><td align='left'>
<a href="works.php" title="Click To See More Work">
<figure>
<img src="img/11.jpg" alt="Picture 2" title="Picture 2">
<figcaption>
project name
<br> Sitting stick figures hunched over their laptops!
See <a href="#">more</a>.
</figcaption>
</figure>
</a>
</td></tr>
</table>
表{
边界塌陷:塌陷;
表布局:固定;
最大宽度:100%
}
身材{
显示:块;
前边缘:1米;
后边距:1米;
保证金开始:40px;
边缘端:40px;
}
图img{
填充物:5px;
背景:#fff;
}
菲卡普顿{
填充物:5px;
字体系列:“樱桃花”,草书;
字号:1em;
字号:700;
边界:无;
背景:透明;
换字:正常;
文本对齐:居中;
}
a{
文字装饰:无;
}
.
我的要求是,当调用第四个图像时,它应该自动落在下一行。请建议如何进行。是否有其他方法可以更好地完成我正在做的事情 最简单的方法是使用服务器端语言。 如果您使用PHP,您可以这样做
<table>
<tr>
<?php for(int i=0; i<number_of_images; i++){ ?>
<td align='left'>
<a href="works.php" title="Click To See More Work">
<figure>
<img src="img/11.jpg" alt="Picture 2" title="Picture 2">
<figcaption>
project name<br>Sitting stick figures hunched over their laptops! See <a href="#">more</a>.
</figcaption>
</figure>
</a>
</td>
<?php
if(i%3 == 0){ echo "</tr><tr>";}
}
?>
</tr>
</table>
.
您在这里使用的是服务器端语言吗?您不能将
标记放入另一个
标记中,它将无法正常工作。