调整图像的宽度和高度

时间:2019-04-17 03:46:07

标签: php html mysql

我的内容存储在mysql中,如下所示:

<table width="450" cellspacing="1" cellpadding="1" border="1">
    <tbody>
        <tr>
            <td><img width="513" height="680" align="left" alt=" src="/userfiles/image/pic.jpg" /></td>
            <td><img width="315" height="700" align="left" alt=" src="/userfiles/image/DSC_0389.JPG" /></td>
            <td><img width="580" height="320" align="left" alt=" src="/userfiles/image/ktxh.jpg" /></td>
        </tr>
    </tbody>
</table>

当我从db,PHP加载并通过PHP在html中显示时,没有问题。

现在,我希望所有图像以固定的宽度和高度显示为200 X 200 AND TABLE BORDER ='0'

<table width="200" cellspacing="1" cellpadding="1" border="0">
    <tbody>
        <tr>
            <td><img width="200" height="200" align="left" alt=" src="/userfiles/image/pic.jpg" /></td>
            <td><img width="200" height="200" align="left" alt=" src="/userfiles/image/DSC_0389.JPG" /></td>
            <td><img width="200" height="200" align="left" alt=" src="/userfiles/image/ktxh.jpg" /></td>
        </tr>
    </tbody>
</table>

我该如何解决这个问题?

2 个答案:

答案 0 :(得分:0)

替换为此代码和CSS

<style>
 .cstm
 {
   width:200px;
   height:200px
 }
 table
 {
  border:0
 }
</style>

<table width="200" cellspacing="1" cellpadding="1" border="0">
    <tbody>
        <tr>
            <td><img class="cstm" align="left" alt=" src="/userfiles/image/pic.jpg" /></td>
            <td><img class="cstm" align="left" alt=" src="/userfiles/image/DSC_0389.JPG" /></td>
            <td><img class="cstm" align="left" alt=" src="/userfiles/image/ktxh.jpg" /></td>
        </tr>
    </tbody>
</table>

答案 1 :(得分:0)

正如您提到的$ content是动态的那样,您可以尝试将样式添加到表格中吗?

 <style>
 table td>img
 {
   width:200px;
   height:200px
 }

</style>
相关问题