Home Web Front-end JS Tutorial How to adapt the bottom suction button to iPhone X in WeChat mini program (detailed tutorial)

How to adapt the bottom suction button to iPhone X in WeChat mini program (detailed tutorial)

Jun 23, 2018 pm 03:35 PM
iphone x

This article mainly introduces the solution for adapting the bottom button of the WeChat applet to iPhone are arriving one after another, and the tycoons around them are using them one after another. Because the iPhone There are also a few places where the user experience is not good, mainly on the product details page and the bottom button bar of the shopping cart, which overlap with the Home Indicator bar. This makes it easy to accidentally trigger gesture operations when clicking the button below, as shown below. :

The screenshots are from the Internet. If the infringement or deletion is

, it must be fixed if it is a bug, and it must be optimized if it is an experience problem, so I immediately bought an iPhone X and started Research.

The adaptation on the web page is good, with the viewport meta tag and the following solution for processing. For details, please see here

{
 position: fixed;
 bottom: 0;
 width: 100%;
 height: constant(safe-area-inset-bottom);
 background-color: #fff;
}
Copy after login

But it’s quite embarrassing. From the appearance of the four corners being cut off, it can be inferred that the viewport-fit in the mini program defaults to cover (guessed based on the performance), but there is no interface to change it. Therefore, the adaptation solution on the web page through viewport-fix=cover combined with constant(safe-area-inset-bottom); is not suitable for small programs. At present, we have not seen any mini programs with special interfaces or fields for iPhone X and other special-shaped screens. The adaptation of the bottom tab bar of the applet itself to the iPhone X simply adds a white bottom bar, which improves the position of the original tab bar. Why do you say this? Because this can be seen from our shopping cart page, the bottom sucking operation of the shopping cart page is not implemented through position:fixed;bottom:0;, but the top value is calculated based on the windowHeight-its own height, thereby simulating the bottom sucking, in a small After the new version of the program was adapted to the iPhone X, the button at the bottom of the shopping cart was half covered, which led to the above conclusion.

Getting back to the subject, since there is no special solution to obtain this value, we can only obtain device information through the wx.getSystemInfo interface. The method of using this interface is as follows:

wx.getSystemInfo({
 success: function(res) {
  console.log(res.model)
  console.log(res.pixelRatio)
  console.log(res.windowWidth)
  console.log(res.windowHeight)
  console.log(res.language)
  console.log(res.version)
  console.log(res.platform)
 }
})
Copy after login

where model is the model of the device. If the model contains iPhone

The value can be read in the sub-page, for example, on the product details page:

<!-- goods.wxml -->
<view class="button-group {{isIpx?&#39;fix-iphonex-button&#39;:&#39;&#39;}}">这是一个吸底按钮区域</view>
// goods.js
let app = getApp();
Page({
  data: {
    isIpx: app.globalData.isIpx?true:false
  }
})
/* app.wxss */
.fix-iphonex-button {
  bottom:68rpx!important;
}
.fix-iphonex-button::after {
  content: &#39; &#39;;
  position: fixed;
  bottom: 0!important;
  height: 68rpx!important;
  width: 100%;
  background: #fff;
}
Copy after login

So, a simple solution to adapt to the rounded corners at the bottom of iPhone X is completed.

As for why 68rpx is used, because the screen width of iPhone

##Screenshots are from the Internet, and they have been deleted

Screenshots are from the Internet, and they have been deleted

The above is what I compiled for everyone, I hope It will be helpful to everyone in the future.

Related articles:

How to implement two queues to represent a stack in JS

How to implement the front and back ends of the vue project in node Separation

How to build a vue application through vue-cli

How to implement dynamic search using Angularjs filters

The above is the detailed content of How to adapt the bottom suction button to iPhone X in WeChat mini program (detailed tutorial). For more information, please follow other related articles on the PHP Chinese website!

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Best Graphic Settings
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. How to Fix Audio if You Can't Hear Anyone
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
WWE 2K25: How To Unlock Everything In MyRise
1 months ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

iPhone 16 Pro and iPhone 16 Pro Max official with new cameras, A18 Pro SoC and larger screens iPhone 16 Pro and iPhone 16 Pro Max official with new cameras, A18 Pro SoC and larger screens Sep 10, 2024 am 06:50 AM

Apple has finally lifted the covers off its new high-end iPhone models. The iPhone 16 Pro and iPhone 16 Pro Max now come with larger screens compared to their last-gen counterparts (6.3-in on the Pro, 6.9-in on Pro Max). They get an enhanced Apple A1

iPhone parts Activation Lock spotted in iOS 18 RC — may be Apple\'s latest blow to right to repair sold under the guise of user protection iPhone parts Activation Lock spotted in iOS 18 RC — may be Apple\'s latest blow to right to repair sold under the guise of user protection Sep 14, 2024 am 06:29 AM

Earlier this year, Apple announced that it would be expanding its Activation Lock feature to iPhone components. This effectively links individual iPhone components, like the battery, display, FaceID assembly, and camera hardware to an iCloud account,

iPhone parts Activation Lock may be Apple\'s latest blow to right to repair sold under the guise of user protection iPhone parts Activation Lock may be Apple\'s latest blow to right to repair sold under the guise of user protection Sep 13, 2024 pm 06:17 PM

Earlier this year, Apple announced that it would be expanding its Activation Lock feature to iPhone components. This effectively links individual iPhone components, like the battery, display, FaceID assembly, and camera hardware to an iCloud account,

Gate.io trading platform official app download and installation address Gate.io trading platform official app download and installation address Feb 13, 2025 pm 07:33 PM

This article details the steps to register and download the latest app on the official website of Gate.io. First, the registration process is introduced, including filling in the registration information, verifying the email/mobile phone number, and completing the registration. Secondly, it explains how to download the Gate.io App on iOS devices and Android devices. Finally, security tips are emphasized, such as verifying the authenticity of the official website, enabling two-step verification, and being alert to phishing risks to ensure the safety of user accounts and assets.

Multiple iPhone 16 Pro users report touchscreen freezing issues, possibly linked to palm rejection sensitivity Multiple iPhone 16 Pro users report touchscreen freezing issues, possibly linked to palm rejection sensitivity Sep 23, 2024 pm 06:18 PM

If you've already gotten your hands on a device from the Apple's iPhone 16 lineup — more specifically, the 16 Pro/Pro Max — chances are you've recently faced some kind of issue with the touchscreen. The silver lining is that you're not alone—reports

Anbi app official download v2.96.2 latest version installation Anbi official Android version Anbi app official download v2.96.2 latest version installation Anbi official Android version Mar 04, 2025 pm 01:06 PM

Binance App official installation steps: Android needs to visit the official website to find the download link, choose the Android version to download and install; iOS search for "Binance" on the App Store. All should pay attention to the agreement through official channels.

How to solve the problem of 'Undefined array key 'sign'' error when calling Alipay EasySDK using PHP? How to solve the problem of 'Undefined array key 'sign'' error when calling Alipay EasySDK using PHP? Mar 31, 2025 pm 11:51 PM

Problem Description When calling Alipay EasySDK using PHP, after filling in the parameters according to the official code, an error message was reported during operation: "Undefined...

Download link of Ouyi iOS version installation package Download link of Ouyi iOS version installation package Feb 21, 2025 pm 07:42 PM

Ouyi is a world-leading cryptocurrency exchange with its official iOS app that provides users with a convenient and secure digital asset management experience. Users can download the Ouyi iOS version installation package for free through the download link provided in this article, and enjoy the following main functions: Convenient trading platform: Users can easily buy and sell hundreds of cryptocurrencies on the Ouyi iOS app, including Bitcoin and Ethereum. and Dogecoin. Safe and reliable storage: Ouyi adopts advanced security technology to provide users with safe and reliable digital asset storage. 2FA, biometric authentication and other security measures ensure that user assets are not infringed. Real-time market data: Ouyi iOS app provides real-time market data and charts, allowing users to grasp encryption at any time

See all articles