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
4.3k views
in Technique[技术] by (71.8m points)

小程序scroll-view 高度不起作用怎么解决?

小程序写一个音乐播放的界面,歌词滚动单独包装成了组件,但是scroll-view的高度是想给70%但是没反应,目前高度就很长很长,甚至划到下一页。我想知道怎么把歌词的限制在这个黄色的框里。谢谢围观和建议!
lyric1
lyric2
components/lyric/lyric.wxml

<scroll-view hidden="{{isLyricShow}}" class="lyric-scroll" scroll-y scroll-top="{{scrollTop}}" scroll-with-animation="true">
  <view class="lyric-panel">
    <block wx:for="{{lrcList}}" wx:key="item">
      <view class="lyric {{index == nowLyricIndex?'hightlight-lyric': ''}}">{{item.lrc}}</view>
    </block>
  </view>
</scroll-view>

components/lyric/lyric.wxss

.lyric-scroll {
  width: 100%;
  height: 70%;
  color: #ccc;
  font-size: 32rpx;
}

.lyric-panel {
  position: relative;
  top: 50%;
}

.lyric {
  min-height: 64rpx;
}

.hightlight-lyric {
  color: #d43c33;
}

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

1 Reply

0 votes
by (71.8m points)

检查scroll view父级height是否有设置。父级没有height的话,就不好用%单位,可以使用vh 设置scroll view高度


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

...