【问题标题】:CSS Bottom-alignment of two spans within a divdiv内两个跨度的CSS底部对齐
【发布时间】:2017-06-29 00:14:18
【问题描述】:

我正在尝试在 ul-li 上下文中底部对齐 div 元素中的两个 span 元素。两个跨度应该是相邻的,它们之间没有中断。换行应限制在第二个跨度。解决方案的所有尝试要么将第二个跨度放在第一个跨度下方,要么将第二个跨度换行在第一个跨度下方。如何让两个跨度以“小型汽车、大型巴士”的方式对齐?

CSS:

.div
{
  display:table-cell;
  text-align: left;
  vertical-align: bottom;
  white-space: nowrap;
}
.divBottomBoarder
{
  top: 20px;
  margin: 0px;  
  padding: 16px 2px 2px 2px;  
  display: inline-block;
  border-width: 2px;
  border-bottom: 2px black solid;
  width: 100%;
}
.subject
{
  color: white;
  padding: 1px 3px 2px 3px;
  margin-right: 10px;
  background-color: rgb(64,128,128);
  font-weight: bold;
  float: left;
  vertical-align: bottom;
}
.content 
{
  bottom: 0px;
  text-align: left;
  vertical-align: bottom;
}

HTML:

<ul>
  <li>
  <div class='divBottomBoarder'>
  <span class='subject'>A Subject:</span>
  <span class='content'>Extended descriptive text that could line-wrap. If it does, the content text should be left-justified, bottom-aligned with the subject text, dynamically extending upward as required, <b><i>without</i></b> wrapping below the Topic text. Also, the subject and content spans should not line-wrap. The list dot, subject text, and content text should all be bottom-aligned immediately above the bottom border.</span>
  </div>
  </li>
    <ul>
      <li>
          <div class='divBottomBoarder'>
             <span class='subject'>A Child Subject:</span>
             <span class='content'>More descriptive text that could also line-wrap. Again, the content text should be left-justified, bottom-aligned with the subject text, dynamically extending upward as required, <b><i>without</i></b> wrapping below the subject text. Also, the subject and content spans should not line-wrap.  The list dot, subject text, and content text should all be bottom-aligned immediately above the bottom border.</span>
          </div>
      </li>
    </ul>
</ul>

Fiddle me this.

【问题讨论】:

    标签: html css vertical-alignment word-wrap


    【解决方案1】:

    你可以添加这个:

    .divBottomBoarder  {
      display: flex;
      align-items: flex-end;
    }
    

    https://jsfiddle.net/2mpb7493/1/

    【讨论】:

    • 谢谢!并添加“空白:nowrap;”到主题领域正是我要找的!
    猜你喜欢
    • 1970-01-01
    • 2020-02-13
    • 2015-11-30
    • 1970-01-01
    • 1970-01-01
    • 2015-11-12
    • 1970-01-01
    • 1970-01-01
    • 2022-06-28
    相关资源
    最近更新 更多