为什么CSS text-align:left与Simplebar一起使用?

问题描述 投票:0回答:1

我遇到了text-align:left问题:我的邮件(文本)不向左对齐。到目前为止,我已经尝试了几件事:添加width:100%,float:left和display:block。不幸的是,他们都没有工作。我一直在想,也许simplebar会影响它,尽管我不知道该怎么做。如果您能以某种方式帮助我,将不胜感激!这是我的CSS和HTML:

<h2 id="receiver" name="{{receiver}}">Chat with {{receiver}}</h2>
    <div data-simplebar id="my-element" class="history">
      {% for message in hist_list %}
        {{message}}<br>
      {% endfor %}
    </div>

.history {
  position: absolute;
  top: 210px;
  left: 249px;
  transform: translate(-50%, -50%);
  height: 416px;
  text-align:left;
  width:100%;
}
* {
  box-sizing: border-box;
  margin:0;
  padding:0;
  text-align: center;
  font-family: 'Exo', sans-serif;
  color: black;
}

这是Simpebar,可能会干扰我的CSS:

[data-simplebar] {
    position: relative;
    flex-direction: column;
    flex-wrap: wrap;
    justify-content: flex-start;
    align-content: flex-start;
    align-items: flex-start;
}
html css text-align simplebar
1个回答
0
投票

我认为您应该从通用选择器中删除text-align:center;。希望摘要下方的内容有帮助。

* {
  box-sizing: border-box;
  margin:0;
  padding:0;
/*   text-align: center; */
  font-family: 'Exo', sans-serif;
  color: black;
}
#receiver{
  text-align:center;
}

.history {
  position: absolute;
  height: 416px;
  text-align:left;
  width:100%;
}


[data-simplebar] {
    position: relative;
    flex-direction: column;
    flex-wrap: wrap;
    justify-content: flex-start;
    align-content: flex-start;
    align-items: flex-start;
}
<h2 id="receiver" name="">Chat with Name</h2>
<div data-simplebar id="my-element" class="history">
  <p>This is a message</p><br>
  <p>This is a message</p><br>
</div>
© www.soinside.com 2019 - 2024. All rights reserved.