Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
914 views
in Technique[技术] by (71.8m points)

flex 布局的问题 两段文字,一条贴上居中,一条贴下居中

在写微信小程页面时要做到一个效果而且一定要用flex 布局做, 要让starttime贴着上边,endtime贴着下边
,目前用了一个傻办法就是在中间在家了一个有高度的组件把上下撑开, 但应该会出问题, 想求高手告知如何做到,而不是用死办法,

<view class="flex-time">
  <view class="flex-starttime">start</view>
  <view class="flex-block"></view>
  <view class="flex-endtime">end</view>
</view>


  .flex-menu .flex-row {
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  align-items:stretch;
  font-weight: normal;
  font-size: 30rpx;
}
.flex-column{
  margin: 0;
  padding: 10rpx;
  display: flex;
  flex-direction: row;
  align-items:stretch;
  font-weight: normal;
  font-size: 30rpx;
}
.flex-time {
  margin: 0;
  padding:0 10rpx 0 10rpx;
  display: flex;
  flex-direction: column;
  align-content: flex-end;
  border-right:2px #0054a6 solid;
  font-size: 28rpx;
  color: #b2b2b2;
  width: 150rpx;
}
.flex-starttime {
  margin-top: 0;
  padding-top: 0;
  display: inline-flex;
  align-content: flex-center;
}
.flex-endtime {
  margin-bottom: 0;
  padding-bottom: 0;
  display: inline-flex;
  align-content: flex-center;
}
.flex-block {
  height:100rpx;
}

图片描述


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

使用justify-content: space-between;即可

.flex-time {
                  margin: 0;
                  padding:0 10rpx 0 10rpx;
                  display: flex;
                  flex-direction: column;
                  align-content: flex-end;
                  border-right:2px #0054a6 solid;
                  font-size: 28rpx;
                  color: #b2b2b2;
                  width: 150rpx;
                  justify-content: space-between;
                }
                .flex-item {
                    display:flex;
                }
                .flex-cnt {
                    flex: 1;
                }
<view class="flex-item">
    <view class="flex-time">
          <view class="flex-starttime">start</view>
          <view class="flex-endtime">end</view>
        </view>
    <view class="flex-cnt">
        <view>占位</view>
        <view>占位</view>
        <view>占位</view>
        <view>占位</view>
        <view>占位</view>
        <view>占位</view>
        <view>占位</view>
    </view>
</view>

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...