美文网首页【HTML+CSS】
中文上下两端对齐(css)

中文上下两端对齐(css)

作者: 冰冰啦 | 来源:发表于2018-08-13 22:34 被阅读0次

1.html

<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <title>JS Bin</title>
</head>
<body>
<div class="clearfix">
  <span>姓名</span><br>
  <span>联系方式</span>
</div>
</body>
</html>

2.css

div{
  border:1px solid red;
  font-size:20px;
}
span{
  display:inline-block;
  border:1px blue solid;
  width:100px;
  text-align:justify;
  line-height:20px;
  height:20px;
  overflow:hidden;
  
}
span::after{
  content: '';
  display:inline-block;
  width:100%;
  border:1px green solid;
}

3.效果

4.完

相关文章

网友评论

    本文标题:中文上下两端对齐(css)

    本文链接:https://www.haomeiwen.com/subject/krupbftx.html