小编aki*_*tta的帖子


如何将图标对齐到 div 元素内的中心?

我想将图标居中到 div 元素“矩形”。也欢迎任何其他替代解决方案。

body {
  background-color: black;
}

.rectangle {
  width: 125px;
	height: 125px;
	-webkit-border-radius: 5px;
	-moz-border-radius: 5px;
	border-radius: 5px;
	background-color: #fff;
}

h3 {
  color: #fff;
}
Run Code Online (Sandbox Code Playgroud)
<link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet"/>
<div class="rectangle">
  <span><i class="fa fa-quora" aria-hidden="true" style="font-size: 75px;" align="center"></i></span>
</div>
<h3>Quora</h3>
Run Code Online (Sandbox Code Playgroud)

html css center

1
推荐指数
2
解决办法
1万
查看次数