Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/78.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/ms-access/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Html 为什么不是';我的TD元素是否环绕文本内容?_Html_Css - Fatal编程技术网

Html 为什么不是';我的TD元素是否环绕文本内容?

Html 为什么不是';我的TD元素是否环绕文本内容?,html,css,Html,Css,我有一张桌子,左边的td占据了大部分的空间,右边的td几乎没有空间迫使单词断裂 我试图使两个TD的文本内容宽度相同。我在网上做了一些研究,但没有发现能解决这个问题 任何帮助都将不胜感激!下面是我的表格代码和css CSS: #order_info_container { width: 620px; margin-left: auto; margin-right: auto; margin-bottom: 40px; } #customer_service {

我有一张桌子,左边的td占据了大部分的空间,右边的td几乎没有空间迫使单词断裂

我试图使两个TD的文本内容宽度相同。我在网上做了一些研究,但没有发现能解决这个问题

任何帮助都将不胜感激!下面是我的表格代码和css

CSS:

#order_info_container {
    width: 620px;
    margin-left: auto;
    margin-right: auto;
    margin-bottom: 40px;
}

#customer_service {
    padding-top: 10px;
    vertical-align: top;
    text-align : right;
}

#order_information { padding-top: 20px; }

#totals_o {
    padding-top: 20px;
    text-align: right;
}
 <table id='order_info_container'>
  <!--This left td is taking most of the space -->
  <tr>
    <td><img id='o_summary_logo' src='o_summary_logo.png'></td>
    <!--This right td is being squished -->
    <td id='customer_service'><b>Customer Service # (646)-397-5751</b><br>
      Thank you for your business </td>

    <!--This left td is taking most of the space -->
  <tr id='totalswrapper_o'>
    <td id='order_information'>Order Placed - 07/01/14 12:18AM<br>
      <span id='order_number'>Order # - 775</span><br>
      <span class='conf_num'>Confirmation # - 81<br>
      </span></td>

    <!--This right td is being squished -->
    <td id='totals_o'>Sub Total = $28.95<br>
      Tax =   $2.57<br>
      Grand Total =  $33.52<br></td>
  </tr>
</table>
HTML:

#order_info_container {
    width: 620px;
    margin-left: auto;
    margin-right: auto;
    margin-bottom: 40px;
}

#customer_service {
    padding-top: 10px;
    vertical-align: top;
    text-align : right;
}

#order_information { padding-top: 20px; }

#totals_o {
    padding-top: 20px;
    text-align: right;
}
 <table id='order_info_container'>
  <!--This left td is taking most of the space -->
  <tr>
    <td><img id='o_summary_logo' src='o_summary_logo.png'></td>
    <!--This right td is being squished -->
    <td id='customer_service'><b>Customer Service # (646)-397-5751</b><br>
      Thank you for your business </td>

    <!--This left td is taking most of the space -->
  <tr id='totalswrapper_o'>
    <td id='order_information'>Order Placed - 07/01/14 12:18AM<br>
      <span id='order_number'>Order # - 775</span><br>
      <span class='conf_num'>Confirmation # - 81<br>
      </span></td>

    <!--This right td is being squished -->
    <td id='totals_o'>Sub Total = $28.95<br>
      Tax =   $2.57<br>
      Grand Total =  $33.52<br></td>
  </tr>
</table>

客户服务#(646)-397-5751
谢谢你的生意 下订单-2014年1月7日12:18上午
订单号#-775
确认#-81
小计=28.95美元
税=2.57美元
总计=33.52美元

您可以在表格上使用
表格布局:fixed
属性,以便所有单元格具有相同的宽度。关于以下方面的例子:

HTML:


此外,
fixed
布局将自动为任何数量的单元格提供相同的长度比例,即如果有2个单元格,则每个单元格将占表格的50%,3将分别为33%,依此类推……您可以使用小提琴来尝试此操作。

您可以在表格上使用
表格布局:fixed
属性,以便所有单元格具有相同的宽度。关于以下方面的例子:

HTML:


此外,
fixed
布局将自动为任何数量的单元格提供相同的长度比例,即如果有2个单元格,则每个单元格将占表格的50%,3将分别为33%,以此类推……您可以使用小提琴来尝试此操作。

在CSS中为您的
定义50%的宽度应该可以解决此问题。话虽如此,如果您只有2个
,那么50%就可以了

table td{
    width: 50%;
}
。我在小提琴中添加了一个边框,以清楚地显示这种效果


更好的方法是使用
表布局:fixed表上的code>属性
如@arielnmz中建议的。即使您动态生成了列,它也能发挥最佳效果。这样,您就不必计算和定义列占用的空间。他们总是平分。因此,您可能应该采用这种方法

table{
    width: 100%;
    table-layout: fixed;
}

在CSS中为
定义50%的宽度应该可以解决这个问题。话虽如此,如果您只有2个
,那么50%就可以了

table td{
    width: 50%;
}
。我在小提琴中添加了一个边框,以清楚地显示这种效果


更好的方法是使用
表布局:fixed表上的code>属性
如@arielnmz中建议的。即使您动态生成了列,它也能发挥最佳效果。这样,您就不必计算和定义列占用的空间。他们总是平分。因此,您可能应该采用这种方法

table{
    width: 100%;
    table-layout: fixed;
}

图像的大小是多少?超过50%或更少?图像的大小是多少?超过50%或更少?好的,哥们儿。边界塌陷的目的是什么?使细胞通过边界相互粘附(粗略地说),但如果不使用边界,可以将其移除。试着把它放在小提琴上,看看会发生什么。好的,哥们儿。边界塌陷的目的是什么?使细胞通过边界相互粘附(粗略地说),但如果不使用边界,可以将其移除。试着把它从小提琴上移开,看看会发生什么。