1. Single page content cannot be too large
Design Common size:1334/6401134, which contains the height of the signal bar on the top of the phone.
Mobile H5 activity pages often need to be able to share in a variety of social apps, commonly used, QQ and so on.
When using the mobile device to view the page, there is a top navigation bar in the browser, there is not only the top navigation in the QQ built-in browser, the bottom also has the Action bar (Safari browser also), which will occupy the design of the display area, so in the design process need to consider how much content, the bottom of the page to reserve some space , so that in or QQ will not be obscured.
such as (QQ built-in browser): page design size of1334, the top occupies 150px, the bottom occupies 110px, a total of 260px, so the design draft content should be controlled in the height of 1334-260=1074px. When you write your code, use Chrome to simulate the size of your device and save that size (*1074*) for real-time viewing of mobile page effects.
If the page has already been written, you can only adjust the content according to the above dimensions, reduce the element spacing, scale the image size, and so on.
Share my failed attempts:
- If the entire page is scaled (using the META tag), the width will be small and white on both sides according to the design draft ratio;
- Even using REM as the relative spacing unit, there is no way to find a suitable proportion in the two heights (/QQ) to switch, so the unified tune into the appropriate QQ, so even if there is extra blank, fixed the bottom of the guide down arrow can also make it not too abrupt.
750*1334 Page Example 2. Short title
The mobile browser navigation bar has a limited width, and a short title can make it appear intact.
3. Two-dimensional code images introduced using IMG tags
The QR code picture does not write as the element background, otherwise the long press does not have the method to trigger the scanning function. Should be img introduced using tags, as follows:

4. Two-dimensional code picture remember scan test
Sometimes scan the QR code, will jump to an address, unfortunately QQ or will be a warm reminder of this address, as shown:
QQ inside the warm reminder
This prevents some users from continuing to access the product/brand page that the campaign wants to promote, such as the App's download page. Therefore, the QR Code scanning test can not be less.
For example, if the QR code scan results are applied, you can use the micro-app Bao to generate two-dimensional code, which is not "warm reminder".
5. Flatten pictures with Gulp
If you plan to layout first, then use the automation tool to put the picture together, reduce the number of requests, you need to note: When writing CSS, the image width should be fixed, the picture can be flattened to display the image by positioning and displaying the width of the area.
For example, if you use a width: 100%; background-position: center; tool to flatten a picture, the element area (100% of the width) will display other pictures in the layout, which is not what we want to see.
6. About the link sharing-qq
If you share a page link directly to someone else, the person who receives the link message on the phone may see information about the link, such as the page title, description, and picture. The relevant information is set up as follows:
<title>QQ中链接的标题由此处获取</title><meta name="description" content="QQ中链接的描述由此处获取"><!-- QQ默认获取的图片有可能出现缩放问题,效果不佳,可以通过如下方法进行设置 --><meta itemprop="image" content="http://*.*.com/static/images/share.png" />
can refer to the mobile phone QQ interface document: Setshareinfo.
Question: Do you still not see the picture you expect, even if you use the image setting method above?
Resolution: Determine the next you send the link format, will not be omitted, such as: somedomain/ or somedomain/index , the correct should be somedomain/index.html , in order to correctly parse the picture.
If the link is opened, in the QQ built-in browser to choose to share the page, it is generally not wrong.
7. Image compression
Use the Automation tool Gulp-imagemin (tutorial) to compress the picture, for example: 101 KB = 80.7 KB. Later, I used the online tool tinypng another compression, the effect of example: (above using gulp-imagemin compressed pictures) 80.7 KB = 38.1 KB, visible light using automated tools to compress is not enough, most of the picture still has a large compression space, You can throw it in the tinypng and compress it.
8. Loading
Code snippet sharing, take away and use ~
functionLoading){functionLoad () {} Load.prototype.loadImgs =functionUrls,callback) {This.urls = URLs;This.imgnumbers = Urls.length;This.loadimgnumbers =0;var that =ThisForvar i=0;i<urls.length;i++) {var obj =New Image (); OBJ.SRC = Urls[i]; Obj.onload =function) {that.loadimgnumbers++; callback (parseint ((that.loadimgnumbers/that.imgnumbers) *100)); } } };var loader =New Load (); Loader.loadimgs ([Write all picture addresses that need to be loaded here"Http://domain/site/dist/img/XX.png","Http://domain/site/dist/img/XX.png", "Http://domain/site/dist/img/XX.png", "http://domain/site/ Dist/img/xx.png ", " Http://domain/site/dist/img/XX.png ", " http://domain/site/dist/img/XX.png "],function (percent) { //assumes that the element showing percentages is $ (". Percent") $ ( ". Percent"). Text (percent+< Span class= "hljs-string", "%"); //after loading ends, hide the corresponding loading or matte if (percent== 100) {$ ( ' display ', Span class= "hljs-string" > ' none '); } });} //Execute loading method loading ();
9. CSS Animation Property Prefix WebKit
Use CSS3 to make animation effect, the webkit prefix must remember add, or in some mobile phone animation effect is not.
As follows:
-webkit-animation:F.8s 2SForwardsEase-in-out;AnimationF.8s 2SForwardsease-in-out;@-webkit-KeyFrames F {0% {Opacity0;-webkit-transform:Translate3d (750px,0,0);TransformTranslate3d (750px,0,0)}to {opacity: 1; -webkit-transform: translatez (0); transform: translatez (0)}}@ KeyFrames F {0% {opacity: 0; -webkit-transform: translate3d (750px,0,0); transform: translate3d (750px,0,0)} to {opacity: 1; -webkit-transform: translatez (0); transform: translatez (0)}}
It is recommended to use an automated tool to handle non-prefixed CSS files, such as Gulp-autoprefixer.
Mobile-H5 Page considerations