hr不会覆盖图像

时间:2017-03-15 22:02:01

标签: html css

这是一个包含2行的表格。第一行包含hr。第二个表行包含文本和图像。为什么hr不包括图片和文字?



        <table>
            <tr>
                <td align="center">
                    <hr class="hr">
                </td>
            </tr>
            <tr align="center">
                <td width="60%" align="center">
                    <p>
                    Every occasion should be a special one!  No matter the event, a custom-designed cake always adds that special something. 

                    Weddings, birthdays, baby showers, an anniversary...  for ANY event, large or small, let me help you celebrate with a delicious and beautifully-designed and decorated cake!

                    Please take a look through my Cake Photo Gallery to see some of the work I've done recently.

                    Anytime Cakes!  Any cake, any style, any time!!

                    Enjoy!

                    ...Andrea
                    </p>
                </td>
                <td width="40%" align="center">
                    <img src="images/homeimg.jpg">
                </td>
            </tr>
        </table>
&#13;
&#13;
&#13;

3 个答案:

答案 0 :(得分:1)

你的第二行有两个单元格,第一行只有一个单元格。将colspan="2"添加到第一个td,使其宽两列:

&#13;
&#13;
<table>
  <tr>
    <td align="center" colspan="2">
      <hr class="hr">
    </td>
  </tr>
  <tr align="center">
    <td width="60%" align="center">
      <p>
        Every occasion should be a special one! No matter the event, a custom-designed cake always adds that special something. Weddings, birthdays, baby showers, an anniversary... for ANY event, large or small, let me help you celebrate with a delicious and
        beautifully-designed and decorated cake! Please take a look through my Cake Photo Gallery to see some of the work I've done recently. Anytime Cakes! Any cake, any style, any time!! Enjoy! ...Andrea
      </p>
    </td>
    <td width="40%" align="center">
      <img src="images/homeimg.jpg">
    </td>
  </tr>
</table>
&#13;
&#13;
&#13;

答案 1 :(得分:0)

<td colspan="2"><hr/></td>

答案 2 :(得分:0)

您可以使用colspan将两个cols组合在一个列中。

&#13;
&#13;
<table>
            <tr>
                <td align="center" colspan="2">
                    <hr class="hr">
                </td>
            </tr>
            <tr align="center">
                <td width="60%" align="center">
                    <p>
                    Every occasion should be a special one!  No matter the event, a custom-designed cake always adds that special something. 

                    Weddings, birthdays, baby showers, an anniversary...  for ANY event, large or small, let me help you celebrate with a delicious and beautifully-designed and decorated cake!

                    Please take a look through my Cake Photo Gallery to see some of the work I've done recently.

                    Anytime Cakes!  Any cake, any style, any time!!

                    Enjoy!

                    ...Andrea
                    </p>
                </td>
                <td width="40%" align="center">
                    <img src="images/homeimg.jpg">
                </td>
            </tr>
        </table>
&#13;
&#13;
&#13;

有关详细信息,请访问W3C网站:https://www.w3schools.com/tags/att_td_colspan.asp