html表中的换行符

时间:2018-06-13 14:04:25

标签: css html-table html-email line-breaks

我有一个fiddle我从特定设计中复制过来。

我在问题陈述中附上的截图部分。

问题陈述:

我想知道我应该在小提琴中做出哪些改变,以便我能够在截面中显示以下行之间的换行符,这是存在于小提琴中也是。

enter image description here

我在上述行的小提琴中使用的HTML代码片段是:

  <tr>
    <td style="padding-bottom: 3%;text-align:right;">when:</td>
    <td style="padding-bottom: 3%;padding-left: 10%;">March 28/18 @ 7:00pm to March 30/18 @ 7:00pm</td>
  </tr>

2 个答案:

答案 0 :(得分:1)

这就是我所做的:

line-break课程添加到指定的<td>

您可以使用word-wrap: break-word;在div中添加多行文字。 word-wrap基于div的width工作。

&#13;
&#13;
.line-break {
  word-wrap: break-word;
  width: 300px;
}
&#13;
<html>
<body>


<p style="font-size:20px;margin-left:22%;color:#55BEC7;"> hi XYZ, </p>

<table style="width:100%;display: flex;
  justify-content: center;">
  
 <tbody style="font-size:20px;padding-left: 15%;"> 
  <tr>
    <td style="padding-bottom: 3%;text-align:right;">type:</td>
	<td style="padding-bottom: 3%;padding-left: 10%;">availability check request</td>
  </tr>
  <tr>
    <td style="padding-bottom: 3%;text-align:right;">estimated total:</td>
    <td style="padding-bottom: 3%;padding-left: 10%;">$250.00</td>
  </tr>
  <tr>
    <td style="padding-bottom: 3%;text-align:right;">what</td>
    <td style="padding-bottom: 3%;padding-left: 10%;">chainsaw</td>
  </tr>
  <tr>
    <td style="padding-bottom: 3%;text-align:right;">how many</td>
    <td style="padding-bottom: 3%;padding-left: 10%;">2</td>
  </tr>
  <tr>
    <td style="padding-bottom: 3%;text-align:right;">when:</td>
    <td style="padding-bottom: 3%;padding-left: 10%;" class="line-break">March 28/18 @ 7:00pm to March 30/18 @ 7:00pm</td>
  </tr>
  <tr>
    <td style="padding-bottom: 3%;text-align:right;">who:</td>
    <td style="padding-bottom: 3%;padding-left: 10%;color:#FF8D58;">John s</td>
  </tr>
  </tbody>
</table>



<h2 style="text-align:center;color:#484848;margin-top:2.5%;margin-bottom:5%;">steps to earn your money:</h2>
<div class="steps" style="text-align: left;
    margin-left: auto;
    width: 50%;
    padding-right: 0%;
    margin-right: auto;color:#484848;font-size:20px;">
<p>1. click here to open the ABC app to the posting requests page </p>
<p>2. click on availability check request</p>
<p>3. say yes, its availabile ot suggest another date it is</p>
<p>4. wait the 1 or 24 hour confirmation good</p>
<p>5. three days after the booking ends money will be send to your account</p>
</div>
</body>
</html>
&#13;
&#13;
&#13;

此处JSFiddle

答案 1 :(得分:1)

我知道这个问题已经得到解答,但这是另一种可以接近的方法。

注意:我已添加到您的代码中以显示之前的示例。

如果您需要,可以使用相同代码的fiddle

&#13;
&#13;
<html>
<body>


<p style="font-size:20px;margin-left:22%;color:#55BEC7;"> hi XYZ, </p>

<!-- new way -->
<table style="width:100%;">
 <tbody> 
  <tr>
    <td>
        <table style="width:100%;">
         <tbody> 
          <tr>
           <td width="50%" align="right" style="font-family:Arial; font-size:12px;color:#000000;;padding:0px 20px;">type </td>
           <td width="50%" style="font-family:Arial; font-size:12px;color:#000000;text-align:left;padding:0px 10px;">availability check request</td>
	        </tr>
           
          <tr>
           <td width="50%" align="right" style="font-family:Arial; font-size:12px;color:#000000;;padding:0px 20px;">type </td>
           <td width="50%" style="font-family:Arial; font-size:12px;color:#000000;text-align:left;padding:0px 10px;">availability check request</td>
	        </tr>
           
          <tr>
           <td width="50%" align="right" style="font-family:Arial; font-size:12px;color:#000000;;padding:0px 20px;">type </td>
           <td width="50%" style="font-family:Arial; font-size:12px;color:#000000;text-align:left;padding:0px 10px;">availability check request</td>
	        </tr>
         </tbody>
        </table>
    </td>
	  </tr>
  </tbody>
</table>
<!-- new way -->

<table style="width:100%;display: flex;
  justify-content: center;">
  
 <tbody style="font-size:20px;padding-left: 15%;"> 
  <tr>
    <td style="padding-bottom: 3%;text-align:right;">type:</td>
	<td style="padding-bottom: 3%;padding-left: 10%;">availability check request</td>
  </tr>
  <tr>
    <td style="padding-bottom: 3%;text-align:right;">estimated total:</td>
    <td style="padding-bottom: 3%;padding-left: 10%;">$250.00</td>
  </tr>
  <tr>
    <td style="padding-bottom: 3%;text-align:right;">what</td>
    <td style="padding-bottom: 3%;padding-left: 10%;">chainsaw</td>
  </tr>
  <tr>
    <td style="padding-bottom: 3%;text-align:right;">how many</td>
    <td style="padding-bottom: 3%;padding-left: 10%;">2</td>
  </tr>
  <tr>
    <td style="padding-bottom: 3%;text-align:right;">when:</td>
    <td style="padding-bottom: 3%;padding-left: 10%;word-wrap: break-word;
    width: 300px;" >March 28/18 @ 7:00pm to March 30/18 @ 7:00pm</td>
  </tr>
  <tr>
    <td style="padding-bottom: 3%;text-align:right;">who:</td>
    <td style="padding-bottom: 3%;padding-left: 10%;color:#FF8D58;">John s</td>
  </tr>
  </tbody>
</table>



<h2 style="text-align:center;color:#484848;margin-top:2.5%;margin-bottom:5%;">steps to earn your money:</h2>
<div class="steps" style="text-align: left;
    margin-left: auto;
    width: 50%;
    padding-right: 0%;
    margin-right: auto;color:#484848;font-size:20px;">
<p>1. click here to open the ABC app to the posting requests page </p>
<p>2. click on availability check request</p>
<p>3. say yes, its availabile ot suggest another date it is</p>
<p>4. wait the 1 or 24 hour confirmation good</p>
<p>5. three days after the booking ends money will be send to your account</p>
</div>
</body>
</html>
&#13;
&#13;
&#13;

干杯