This article mainly introduces the layout method of flex layout to achieve the upper and lower fixed and middle sliding layout, and shares it with you, as follows: For example, on a page like this, you would like to have a header image, a bottom bar, and a slidable content area in the middle. Briefly introduce how to achieve Fixed header and footer, slideable middle, using flex layout HTML part: <div class="main-warp"> <div class="header"> <img src="imgurl" class="header-img" alt> </div> <div class="content"> <div class="content-scroll"> <div class="shop-box"> <img src="imgurl" alt> </div> <div class="shop-box"> <img src="imgurl" alt > </div> <div class="shop-box"> <img src="imgurl" alt > </div> <div class="shop-box"> <img src="imgurl" alt > </div> </div> </div> <div class="footer"></div> </div> js part: <script> import BScroll from 'better-scroll' export default { data () { return { } }, components: }, methods: { }, computed: { }, mounted () { this.$nextTick(function () { /* eslint-disable no-new */ let pageBottom = document.querySelector('.content') new BScroll(pageBottom, { click: true }) }) }, created () { } } </script> Style part: <style lang="less" rel="stylesheet/less" type="text/less"> @r: 100; // Fixed the head and footer, the middle part is slidable, using flex layout // html, body { background: url("//storage.jd.com/1901/04nianhuojie/02lingquanbg_02.png") repeat-y; background-size: 100%; height: 100%; } .main-warp { max-width: 750px; min-height: 100%; margin: 0 auto; display: flex; flex-direction: column; height: 100%; width: 100%; box-sizing: border-box; .header { height: 500rem / @r; .header-img { height: 500rem / @r; } } .content { flex: 1; width: 100%; overflow: hidden; // overflow: auto; // -webkit-overflow-scrolling: touch; .shop-box { margin: 50rem / @r 0; img { width: 106rem / @r; } } } .footer { background: url("//storage.jd.com/1901/04nianhuojie/fixbtnbg_02.png") repeat; background-size: 12rem / @r 11rem / @r; height: 82rem / @r; width: 100%; bottom: 0; color: #ffdeb8; font-size: 34rem / @r; line-height: 82rem / @r; text-align: center; font-weight: bold; max-width: 750px; } } </style> To explain, on the mobile terminal, if you use overflow:auto; -webkit-overflow-scrolling: touch; On iOS, if the finger slides beyond the area of the box, it is easy to cause the area to not slide when sliding again, as if the finger did not touch the box. Therefore, the BScroll plug-in is used here, and the same is true when using IScroll. Its final effect is to add transition effect to the direct child elements of content. Record this layout here Note: This layout method is not compatible with iOS 9.3 and below. Flex layout should be used with caution when it needs to be compatible with lower versions of iOS. This concludes this article about how flex layout achieves a layout with fixed top and bottom and sliding in the middle. For more relevant flex layout content with fixed top and bottom and sliding in the middle, please search for previous articles on 123WORDPRESS.COM or continue to browse the related articles below. I hope you will support 123WORDPRESS.COM in the future! |
<<: A brief analysis of the differences between undo, redo and binlog in MySQL
Table of contents 1. How to find duplicate rows 2...
This article uses jQuery to implement the sliding...
WebService Remote Debugging In .NET, the remote d...
Preface Students who learn JavaScript know that A...
Table of contents 1. Background running jobs 2. U...
Table of contents JSON.parse JSON.parse Syntax re...
Table of contents 1. Add users 2. Change the user...
This old question has troubled countless front-end...
iOS 1. URL scheme This solution is basically for ...
Table of contents Summarize <template> <...
Borrowing Constructors The basic idea of this t...
Vue recommends using templates to create your HTM...
MySQL 8.0 compressed package installation method,...
This article shares the specific code of JavaScri...
Table of contents background Provide / Inject Ext...