圆圈和文本对齐CSS3



我想完美地对齐圆下的文本。

在这里片段(我简化了所有内容

.circle2 {
  border-radius: 50%;
  width: 18px;
  height: 18px;
  background: RoyalBlue;
  display: inline-block;
  z-index: 2;
}
.wrapper2 {
  display:flex;
  width:100%;
  justify-content: space-around;
  position:relative;
}
.wrapper2:after {
  position:absolute;
  content:'';
  display:block;
  width: 100%;
  top:7px;
  height: 3px;
  background: RoyalBlue;
}
.advanced2 {
  width: 18px;
  height: 18px;
}
.circleActive2 {
  border-radius: 50%;
  width: 25px;
  height: 25px;
  background: RoyalBlue;
  display: inline-block;
}
<div class="w3-container">
  <div class="wrapper2">
    <span>
    <span><div class="circle2 advanced2" ></div>test</span>
    <span><div class="circle2 advanced2 circleActive2" ></div>test2</span>
    <span><div class="circle2 advanced2" ></div>test3</span>
        <span><div class="circle2 advanced2" ></div>test4</span>
        <span><div class="circle2 advanced2" ></div>test5</span>
      </span>
 </div>
</div>

.circles {
  display: flex;
  width: 100%;
  justify-content: space-around;
  position: relative;
}
.circles:after {
  position: absolute;
  content: '';
  display: block;
  width: 100%;
  top: 7px;
  height: 3px;
  background: RoyalBlue;
}
.circles > div {
  display: flex;
  flex-direction: column;
  align-items: center;  
}
.circle {
  border-radius: 50%;
  width: 17px;
  height: 17px;
  background: RoyalBlue;
}
.circle.active {
  width: 25px;
  height: 25px;
  margin-top: -4px;
}
<div class="circles">
  <div><span class="circle"></span>test</div>
  <div><span class="circle active"></span>test2</div>
  <div><span class="circle"></span>test3</div>
  <div><span class="circle"></span>test4</div>
  <div><span class="circle"></span>test5</div>
</div>

我想它应该如下:您可以将" .wrapper2"的最大宽度和边距更改为无问题。

.wrapper2 {
	width:100%;
	position:relative;
	text-align:center;
	max-width:600px;
	margin:50px auto;
}
.wrapper2 > span {
	position:relative;
	width:100%;
	-webkit-flex-flow: row wrap;
	-moz-flex-flow: row wrap;
	flex-flow: row wrap;
	-webkit-justify-content: space-around;
	-moz-justify-content: space-around;
	justify-content: space-around;
	display: -webkit-flex;
	display: -moz-flex;
	display: flex;
}
.wrapper2:after {
	content:"";
	position:absolute;
	display:block;
	width: 100%;
	top:7px;
	left:0;
	height: 4px;
	background: RoyalBlue;
}
.advanced2 {
	width: 18px;
	height: 18px;
	display:block;
	position:relative;
	margin: 0 auto 5px;
	border-radius: 50%;
	width: 18px;
	height: 18px;
	background: RoyalBlue;
	z-index: 2;
}
.circleActive2 {
	margin: -4px auto 1px;
	width: 26px;
	height: 26px;
}
.advanced2 + i {
	font-style:normal;
	display:block;
}
<div class="wrapper2">
  <span>
    <span><div class="advanced2"></div><i>test</i></span>
    <span><div class="advanced2 circleActive2"></div><i>test2</i></span>
    <span><div class="advanced2"></div><i>test3</i></span>
    <span><div class="advanced2"></div><i>test4</i></span>
    <span><div class="advanced2"></div><i>test5</i></span>
   </span>
</div>

希望我能提供帮助!

最新更新