Div中的内容放置

时间:2017-07-18 15:27:08

标签: html

如何让.a在最左边,.b在中间,而.c在最右边?

  <div class="footer1">
              <span class="a">Located At</span>
              <span class="b">Phone Number</span>
              <span class="c">Website By</span>
            </div>

3 个答案:

答案 0 :(得分:4)

您可以使用弹性箱。

.footer1 {
  display: flex;
  justify-content: center;
}

.footer1 span {
  margin: auto;
} 
 <div class="footer1">
  <span class="a">Located At</span>
  <span class="b">Phone Number</span>
  <span class="c">Website By</span>
</div>

答案 1 :(得分:1)

如果你真的希望跨度在远处,我会推荐这个CSS代码:

.footer1{
   display: block;
   text-align:center; 
}

.a {   
   float: left; 
}

.b {
   margin: 0, auto;
   text-align: center; 
}

.c {
   float: right; 
}

答案 2 :(得分:0)

你可以试试这个

.footer1{
    display: flex;  
}
.footer1 span{
    width: 33%;
}
.c{
    text-align: right;
}
<div class="footer1">
  <span class="a">Located At</span>
  <span class="b">Phone Number</span>
  <span class="c">Website By</span>
</div>

如果要集中中间元素

,请在样式中包含.b {text-align:center}