如何在一行中对齐跨度

时间:2019-05-27 18:50:00

标签: python html css django

大家好,我在Django for循环创建的Django模板中有div,我在一个div中有2个跨度,除以很多空格,我想做的是将第二个跨度与制表符对齐在一堂课上,我该如何完成?

我尝试添加填充,边距,但是没有用

HTML:

<div>
     {% for entries in mylist %}
   <div class="ladder"> <span class="player"> {{ entries.0 }}</span> <span class="tab"> {{ entries.1 }} </span></div>
     {% endfor %}


</div>

CSS:

player { margin-left: 20px; 
    }

   .ladder{ width: 30%;
   border: solid 2px blue;
   margin-left: 20px;
   margin-bottom: 30px;
 }

   .tab { 

       margin-left: 40%;  }

https://i.stack.imgur.com/alGa7.png 我现在无法嵌入图片,因此我获得了此链接来显示当前情况,我想要的是数字对齐在一行中。

1 个答案:

答案 0 :(得分:0)

dl {
  width: 100%;
  overflow: hidden;
  background: #ff0;
  padding: 0;
  margin: 0
}
dt {
  float: left;
  width: 50%;
  /* adjust the width; make sure the total of both is 100% */
  background: #cc0;
  padding: 0;
  margin: 0
}
dd {
  float: left;
  width: 50%;
  /* adjust the width; make sure the total of both is 100% */
  background: #dd0
  padding: 0;
  margin: 0
}

<dl>
  <dt>Mercury</dt>
  <dd>Ερμής</dd>
  <dt>Venus</dt>
  <dd>Αφροδίτη</dd>
  <dt>Earth</dt>
  <dd>Γη</dd>
</dl>