【问题标题】:How to span this text across?如何跨越这个文本?
【发布时间】:2021-09-24 16:37:04
【问题描述】:

我在表格行中的表格单元格中有一些文本,我试图让文本跨度。 文字一直停在原地。

这是我目前拥有的:

但这正是我想要的:

我希望文本跨越所有方式。 我将如何实现它?

这是我的代码:

.normal-cell-styling-left-second {
  width: 350px;
  padding-top: 20px;
  padding-bottom: 20px;
  border-bottom: 1px solid #E6E6E6;
}

.normal-cell-styling-middle-second {
  width: 425px;
  padding-left: 60px;
  padding-top: 20px;
  padding-bottom: 20px;
  border-bottom: 1px solid #E6E6E6;
}

.normal-cell-styling-right-second {
  width: 700px;
  padding-top: 20px;
  padding-left: 200px;
  padding-bottom: 20px;
  border-bottom: 1px solid #E6E6E6;
}

.gray-dynamic {
  display: inline-block;
  background-color: #F6F8FA;
  padding-top: 5px;
  padding-bottom: 5px;
  padding-left: 5px;
  padding-right: 5px;
  border-radius: 4px;
  margin-top: 5px;
  margin-bottom: 5px;
  font-weight: normal;
  font-size: 16px;
  font-family: 'PureHeadlineRegular', Sans-serif;
  line-height: 19px;
  color: #212121;
}

.image-placeholder5 {
  display: inline-block;
  width: 196px;
  height: 36px;
  background-color: #F1F1F1;
}
<table>
  <tr>
    <td className="normal-cell-styling-left-second">
      <span class="gray-dynamic">
      SHADOW_SPREAD_0 
    </span>
    </td>
    <td className="normal-cell-styling-middle-second">
      0 0 0px 0 rgba(0,0,0,0.12) <br></br>0 0px 0px 0 rgba(0,0,0,0.24)
    </td>
    <td className="normal-cell-styling-right-second">
      <div className="image-placeholder5"></div>
    </td>
  </tr>
  <table>

【问题讨论】:

  • 这能回答你的问题吗? stackoverflow.com/questions/572298/…
  • 当我运行 sn-p 时,我得到的图片与您显示的所需布局相同,除非我将它放在一个非常窄的设备上 - 当它必须环绕时。您使用的是什么系统/设备。
  • 我将其设置为 918px 屏幕
  • isherwood,那个堆栈帖子修复了它,谢谢。

标签: html css


【解决方案1】:

不确定,但您似乎对表格样式有些不熟悉:

这里有一个sn-p,可能更接近你的期望,毫不犹豫地澄清你的需求和对我自己的误解。

table{
border-spacing:0;/* or border-collapse:collapse; */
}
.normal-cell-styling-left-second {
  width: 350px;
  border-bottom: 1px solid ;
  vertical-align:top;
}

.normal-cell-styling-middle-second {
  width: 425px;
  padding-left: 60px;/* needed ?*/
  border-bottom: 1px solid ;
  white-space:nowrap;
}

.normal-cell-styling-right-second {
  border-bottom: 1px solid ;
}

.gray-dynamic {
  display: inline-block;
  background-color: #F6F8FA;
  padding-top: 5px;
  padding-bottom: 5px;
  padding-left: 5px;
  padding-right: 5px;
  border-radius: 4px;
  margin-top: 5px;
  margin-bottom: 5px;
  font-weight: normal;
  font-size: 16px;
  font-family: 'PureHeadlineRegular', Sans-serif;
  line-height: 19px;
  color: #212121;
}

.image-placeholder5 {
  display: inline-block;
  width: 196px;
  height: 36px;
  background-color: #F1F1F1;
}
<table>
  <tr>
    <td class="normal-cell-styling-left-second">
      <span class="gray-dynamic">
      SHADOW_SPREAD_0 
    </span>
    </td>
    <td class="normal-cell-styling-middle-second">
      0 0 0px 0 rgba(0,0,0,0.12) <br>0 0px 0px 0 rgba(0,0,0,0.24)
    </td>
    <td class="normal-cell-styling-right-second">
      <div class="image-placeholder5"></div>
    </td>
  </tr>
  <table>

【讨论】:

    【解决方案2】:

    修改css

    .table thead tr th td { 
        white-space:nowrap
    }
    

    然后在表格数据样式中使用white-space-no-wrap

    <td style="white-space:nowrap;" className="normal-cell-styling-middle-second"> 0 0 0px 0 rgba(0,0,0,0.12) <br></br>0 0px 0px 0 rgba(0,0,0,0.24) </td>
    

    【讨论】:

      【解决方案3】:

      只要把它放在像你的 SHADOW_SPREAD 这样的跨度中

      .normal-cell-styling-left-second {
        width: 350px;
        padding-top: 20px;
        padding-bottom: 20px;
        border-bottom: 1px solid #E6E6E6;
      }
      
      .normal-cell-styling-middle-second {
        width: 425px;
        padding-left: 60px;
        padding-top: 20px;
        padding-bottom: 20px;
        border-bottom: 1px solid #E6E6E6;
      }
      
      .normal-cell-styling-right-second {
        width: 700px;
        padding-top: 20px;
        padding-left: 200px;
        padding-bottom: 20px;
        border-bottom: 1px solid #E6E6E6;
      }
      
      .gray-dynamic {
        display: inline-block;
        background-color: #F6F8FA;
        padding-top: 5px;
        padding-bottom: 5px;
        padding-left: 5px;
        padding-right: 5px;
        border-radius: 4px;
        margin-top: 5px;
        margin-bottom: 5px;
        font-weight: normal;
        font-size: 16px;
        font-family: 'PureHeadlineRegular', Sans-serif;
        line-height: 19px;
        color: #212121;
      }
      
      .image-placeholder5 {
        display: inline-block;
        width: 196px;
        height: 36px;
        background-color: #F1F1F1;
      }
      <table>
        <tr>
          <td className="normal-cell-styling-left-second">
            <span class="gray-dynamic">
            SHADOW_SPREAD_0 
          </span>
          </td>
          <td className="normal-cell-styling-middle-second">
          <span class="gray-dynamic">
            0 0 0px 0 rgba(0,0,0,0.12) <br>0 0px 0px 0 rgba(0,0,0,0.24)
            </span>
          </td>
          <td className="normal-cell-styling-right-second">
            <div className="image-placeholder5"></div>
          </td>
        </tr>
        <table>

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2012-04-28
        • 2011-09-23
        • 2011-08-18
        • 1970-01-01
        • 1970-01-01
        • 2013-09-27
        相关资源
        最近更新 更多