【问题标题】:How to center text columns in CSS如何在 CSS 中将文本列居中
【发布时间】:2018-01-08 17:52:49
【问题描述】:

在一个小型(初学者)项目中,我有两个文本列,我和朋友正在努力。这是我们的代码。

h3 {
text-align: left;
font-family: Times;
display:flex;
align-items:center;
}



.AboutBA {
text-align: justify;
width: 400px;
height: 300px;
position: relative;
left: 190px;

}

.Position {
text-align: justify;
width: 400px;
height: 300px;
position: relative;
left: 650px;
bottom: 319px;
}

我不想改变太多,为了不破坏布局,我唯一要寻找的是将两个文本列居中,使它们位于上图下方。

Here is how the code looks as of now.

【问题讨论】:

  • 能不能把要居中的文本列对应的HTML代码加进去?
  • 看看html会很有帮助:)
  • 将它们设为inline-block 并在父级codepen.io/mcoker/pen/KvMVyd 上使用text-align: center
  • 还有 display:table + margin:auto 用于父级和 table-cell 用于两个子级......但仍然缺少 HTML

标签: html css text alignment center


【解决方案1】:

    .textDiv {
        width: 100%;
        background-color: #CDD0E1;
        position: absolute;
        bottom: 0;
        right: 0;
        display: table;
        height:200px;
    }

        .textDiv div {
            float: left;
            width: 35%;
            padding:10px 5% 20px;
            display: inline-table;
        }
  .textDiv div span {
                 text-align: justify;
                  font-size: 13px;
            }
            .textDiv div strong {
                font-size: 16px;
                line-height: 40px;
                text-align: left !important;
            }
<div class="textDiv">
  <div>
     <strong>  teacher empowers kids</strong>
     <br />
     <span>Chris Ulmer, 28, reflects on the decision to leave his teaching career in order to focus on a worldwide mission.
     </span>
  </div>
  <div>
     <strong> How he found his calling</strong>
     <br />
     <span> Ulmer, originally from Philadelphia, attended Penn State where he majored in media effects, or “the way social media affects those who take it in,” he explains.
     </span>
   </div>
</div>

【讨论】:

    猜你喜欢
    • 2018-01-11
    • 2021-05-17
    • 2019-10-26
    • 2015-04-08
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-06-18
    相关资源
    最近更新 更多