【问题标题】:Images side to side on html图片并排在html上
【发布时间】:2018-03-01 09:24:05
【问题描述】:

我正在编辑一个仅使用 760 宽图像的表格。 现在我需要并排放置 2x 380 宽度的图像,但它不起作用。任何人都可以帮忙吗?非常感谢!

我已突出显示评论“我在这里遇到问题”的部分。请检查。

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<title>TITLE</title>
<html style="opacity: 1;" xmlns="http://www.w3.org/1999/xhtml">
<head>
   <title></title>
   <meta content="text/html; charset=UTF-8" http-equiv="Content-Type" />
</head>
<body bgcolor="#FFFFFF" style="margin: 0px; padding: 0px; background-color: rgb(255, 255, 255);">
<table bgcolor="#ffffff" border="0" cellpadding="0" cellspacing="0" style="background-color:#f4f4f4;" width="100%">
   <tbody>
      <tr>
        <td align="center"><!-- Header -->
         <table border="0" cellpadding="0" cellspacing="0" width="760">
            <tbody>
               <tr>
                  <td align="center">
                  <p style="color: #f4f4f4;font-size:1px;">Hello
                  </p>

                  <p align="center" style="color:#777777;font-size:11px;font-family:Arial,sans-serif;text-align:center;padding:10px"><a href="http://www*********" style="color:#777777" target="_blank">Online version</a> 
                  </p>
                  </td>
               </tr>
            </tbody>
         </table>

         <table align="center" border="0" cellpadding="0" cellspacing="0" width="760">
            <tbody>
               <tr>
                  <td width="760"><a border="0" ><img alt="Banner" border="0" height="224" src="http://www.************" style="display:block;border:0 none" title="Banner" width="760" /> </a></td>
                                 </tr>
            </tbody>
         </table>
         <!-- End Header-->

         <table align="center" border="0" cellpadding="0" cellspacing="0" itemscope="" itemtype="http://schema.org/Offer" style="background-color:#FFFFFF;" width="760">
            <tbody><!-- Main -->
               <tr>
                  <td align="center" colspan="2">
                  <table align="center" border="0" cellpadding="0" cellspacing="0">
                     <tbody>
                        <tr>
                           <td align="left"><a border="0" href="htt***************" target="_blank"><img alt="Intro" border="0" src="http://www**********.jpg?1502297240" style="display:block" title="Intro" /> </a></td>
                        </tr>
                        <tr>
                           <td align="left"><a border="0" href="http***************" target="_blank"><img alt="******" border="0" src="http://www*********/3.jpg?1502297240" style="display:block" title="*****" /> </a></td>
                        </tr>
                        <tr>
                           <td align="left"><a border="0" href="http************" target="_blank"><img alt="******" border="0" src="http://www************4.jpg?1502297240" style="display:block" title="****************" /> </a></td>
                        </tr>

<!--I'M HAVING TROUBLE HERE-->


                        <tr>
                           <td align="left"><a border="0" href="*******************" target="_blank"><img alt="LEFT PICTURE" border="0" src="http://www********5.jpg?1502297240" style="display:block" title="LEFT PICTURE" /> </a></td>
                        </tr>
                        <tr>
                           <td align="right"><a border="0" href="https://www***************" target="_blank"><img alt="RIGHT PICTURE" border="0" src="http://www**********6.jpg?1502297240" style="display:block" title="RIGHT PICTURE" /> </a></td>
                        </tr>
                                             </tbody>
                  </table>
                  </td>
               </tr>
               <!-- End -->
            </tbody>
         </table>


           <!-- Unsubscribe to anti cancer foundation -->

         <table border="0" cellpadding="10" cellspacing="4" height="70" style="margin-bottom:20px;margin-top:20px;" width="504">
            <tbody>
              <tr>
                <td style="background-color:#FFFFFF;border:1px solid #d1d1d1">
                  <center style="font-family: Arial,Helvetica,sans-serif;font-size:13px;">
                  <p style="margin:0;color:#444">
																<br>
																**************</span><br>
																<br>
																<a href="*******************</a>
                  </p>
                  </center>
                 </td>
</tr>
            </tbody>
         </table>
         <!-- Donations --></td>
      </tr>
   </tbody>
</table>


<table bgcolor="#f4f4f4" border="0" cellpadding="0" cellspacing="0" style="background-color:#f4f4f4" width="100%">
   <tbody>
      <tr>
         <td align="center">
         <p align="center" style="color:#444444;font-size:11px;font-family:Arial,sans-serif;text-align:center;padding:10px"><br>**********</br>
		  <br>************</br><br>**************</br><br>***********</br><br>***********</br><br><a href="**************">***************</a></br><br><a href=".***********">***************</a></br>

         </p>
         </td>
      </tr>
         </tbody>
</table>
</body>
</html>

另外,如果您看到完全不需要的内容,请也删除。 我很确定整个代码可以缩短。

【问题讨论】:

    标签: html image html-table


    【解决方案1】:

    使用 tr, td 如下图并排显示

    <tr>
         <td><img style="float:left;width:380px" ><img style="float:right;width:380px"></td>
    </tr>
    
     
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <title>TITLE</title>
    <html style="opacity: 1;" xmlns="http://www.w3.org/1999/xhtml">
    <head>
       <title></title>
       <meta content="text/html; charset=UTF-8" http-equiv="Content-Type" />
    </head>
    <body bgcolor="#FFFFFF" style="margin: 0px; padding: 0px; background-color: rgb(255, 255, 255);">
    <table bgcolor="#ffffff" border="0" cellpadding="0" cellspacing="0" style="background-color:#f4f4f4;" width="100%">
       <tbody>
          <tr>
            <td align="center"><!-- Header -->
             <table border="0" cellpadding="0" cellspacing="0" width="760">
                <tbody>
                   <tr>
                      <td align="center">
                      <p style="color: #f4f4f4;font-size:1px;">Hello
                      </p>
    
                      <p align="center" style="color:#777777;font-size:11px;font-family:Arial,sans-serif;text-align:center;padding:10px"><a href="http://www*********" style="color:#777777" target="_blank">Online version</a> 
                      </p>
                      </td>
                   </tr>
                </tbody>
             </table>
    
             <table align="center" border="0" cellpadding="0" cellspacing="0" width="760">
                <tbody>
                   <tr>
                      <td width="760"><a border="0" ><img alt="Banner" border="0" height="224" src="http://www.************" style="display:block;border:0 none" title="Banner" width="760" /> </a></td>
                                     </tr>
                </tbody>
             </table>
             <!-- End Header-->
    
             <table align="center" border="0" cellpadding="0" cellspacing="0" itemscope="" itemtype="http://schema.org/Offer" style="background-color:#FFFFFF;" width="760">
                <tbody><!-- Main -->
                   <tr>
                      <td align="center" colspan="2">
                      <table align="center" border="0" cellpadding="0" cellspacing="0">
                         <tbody>
                            <tr>
                               <td align="left"><a border="0" href="htt***************" target="_blank"><img alt="Intro" border="0" src="http://www**********.jpg?1502297240" style="display:block" title="Intro" /> </a></td>
                            </tr>
                            <tr>
                               <td align="left"><a border="0" href="http***************" target="_blank"><img alt="******" border="0" src="http://www*********/3.jpg?1502297240" style="display:block" title="*****" /> </a></td>
                            </tr>
                            <tr>
                               <td align="left"><a border="0" href="http************" target="_blank"><img alt="******" border="0" src="http://www************4.jpg?1502297240" style="display:block" title="****************" /> </a></td>
                            </tr>
    
    <!--I'M HAVING TROUBLE HERE-->
    
    
                            <tr>
                               <td align="center"><a border="0" href="*******************" target="_blank"><img alt="LEFT PICTURE" style="float:left;width:380px" border="0" src="http://www********5.jpg?1502297240" style="display:block" title="LEFT PICTURE" /> </a><a border="0" href="https://www***************" target="_blank"><img alt="RIGHT PICTURE" style="float:right;width:380px" border="0" src="http://www**********6.jpg?1502297240" style="display:block" title="RIGHT PICTURE" /> </a></td>
                           
                         
                            </tr>
                                                 </tbody>
                      </table>
                      </td>
                   </tr>
                   <!-- End -->
                </tbody>
             </table>
    
    
               <!-- Unsubscribe to anti cancer foundation -->
    
             <table border="0" cellpadding="10" cellspacing="4" height="70" style="margin-bottom:20px;margin-top:20px;" width="504">
                <tbody>
                  <tr>
                    <td style="background-color:#FFFFFF;border:1px solid #d1d1d1">
                      <center style="font-family: Arial,Helvetica,sans-serif;font-size:13px;">
                      <p style="margin:0;color:#444">
    																<br>
    																**************</span><br>
    																<br>
    																<a href="*******************</a>
                      </p>
                      </center>
                     </td>
    </tr>
                </tbody>
             </table>
             <!-- Donations --></td>
          </tr>
       </tbody>
    </table>
    
    
    <table bgcolor="#f4f4f4" border="0" cellpadding="0" cellspacing="0" style="background-color:#f4f4f4" width="100%">
       <tbody>
          <tr>
             <td align="center">
             <p align="center" style="color:#444444;font-size:11px;font-family:Arial,sans-serif;text-align:center;padding:10px"><br>**********</br>
    		  <br>************</br><br>**************</br><br>***********</br><br>***********</br><br><a href="**************">***************</a></br><br><a href=".***********">***************</a></br>
    
             </p>
             </td>
          </tr>
             </tbody>
    </table>
    </body>
    </html>

    【讨论】:

    • 我运行这段代码 sn-p,它解决了并排的 img 问题,让我知道它是否适合你
    • 您好,感谢您的回复。它实际上会使它们上面的其他表格错位,我不明白。倒霉……
    • 澄清当我做你的改变时会发生什么imgur.com/a/B51WU
    • @Roberto,我已经更新了答案,请试试这个并告诉我
    • 感谢您的努力。仍然没有工作,他们现在已经互相超越了。 imgur.com/a/B51WU
    猜你喜欢
    • 1970-01-01
    • 2022-01-01
    • 1970-01-01
    • 2011-02-19
    • 1970-01-01
    • 2013-06-11
    • 2014-09-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多