繁体   English   中英

调整图像的宽度和高度

[英]Resize width and height of images

我有内容存储在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>

我该如何解决这个问题?

替换为此代码和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>

正如您所提到的,$ content是动态的,您可以尝试将样式添加到表中:

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

</style>

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM