CSS Flex 实现 Alignment Shifting Wrapping

实现效果:

1、用 float 实现

.html:

<h3 class="title float-title">
  <span class="title-main">Main Title Here</span>
  <span class="title-note">This subtitle is floated.</span>
</h3>

.css:

.title {
  border-bottom: 1px solid #ccc;
  margin: 40px auto;
}
.title-note {
  font-size: 60%;
  color: #999;
}

.float-title {
  .title-note {
    float: right;
    position: relative;
    top: 12px;
  }
}

2、用 flex 实现

.html:

<h3 class="title flex-title">
  <span class="title-main">Main Title Here</span>
  <span class="title-note">This is a good look, right here.</span>
</h3>

.css:

.title {
  border-bottom: 1px solid #ccc;
  margin: 40px auto;
}
.title-note {
  font-size: 60%;
  color: #999;
}

.flex-title {
  display: flex;
  align-items: flex-end;
  flex-wrap: wrap;
  .title-main {
    flex-grow: 1;
  }
}
posted @ 2020-08-09 22:47  Leophen  阅读(36)  评论(0编辑  收藏  举报