首页 > 解决方案 > 在内联元素的下一行显示文本

问题描述

你能告诉我如何将日期打破到下一行吗?我尝试了很多方法。但没有运气。

我试过这个。但是没有效果。

.not:after {
    content: '\A';
    white-space: pre;
}

.html

       <p class="not">{{item.domain}}
              <em>{{item.date | date:'yyyy-MM-dd'}}</em>
              <span>
                ${{item.price}}
              </span>
            </p>

.scss

.not {
    line-height: 48px;
    padding: 5px 10px 5px 15px;
    height: 55px;
    background: white;
    border-radius: 5px;
    border-bottom: 1px solid #56cde0;
    font-weight: bold;
    width: 90%;
}

.not span {
    float: right;
    color: #9bb0bf;
    font-weight: normal;
    font-size: 16px;
}

用户界面

在此处输入图像描述

标签: htmlcsssass

解决方案


你差不多好了,只需将\A技巧应用于em伪元素

.not em:before {
  content: '\A';
  white-space: pre;
}

.not {
   line-height: 18px; /*Updated this*/
    padding: 5px 10px 5px 15px;
    height: 55px;
    background: white;
    border-radius: 5px;
    border-bottom: 1px solid #56cde0;
    font-weight: bold;
    width: 90%;
}

.not span {
  margin-top:-15px; /*If you want to keep the price on the top*/
  float: right;
  color: #9bb0bf;
  font-weight: normal;
  font-size: 16px;
}
<p class="not">domain.com
  <em>1990-10-10</em>
  <span>
    $8000
</span>
</p>


推荐阅读