Recently found in UC through the Display:inline-block layout a bit of a problem, the full use of the latest version: Android6 system and the latest version of UC mobile phone browser are still problematic.
Design Requirements: Navigation bar 100% width, a total of 4 sub-columns, each column occupies 1/4 width.
The HTML code is:
<ul> <Li></Li> <Li></Li> <Li></Li> <Li></Li></ul>
Method one: Through the "display:inline-block;" To layout, which is set by the parent element "font-size:0;" Removes the default spacing for child element Inline-block.
ul { width: 100%; font-size: 0; } Li { display: inline-block; width: 25%;
height: 100px; }
The result is that the mobile browser behaves well, except for the UC browser (left as the normal browser and right for the UC browser):
It appears that setting the parent element "font-size:0" under UC does not eliminate the default spacing of child elements inline-block.
Let's change the method of eliminating spacing-changing the way HTML tags are written.
Method Two: The HTML end tag and the start tag are not left blank
<ul> <Li></Li><Li></Li><Li></Li><Li></Li></ul>
Or:
<ul> <Li> </Li><Li> </Li><Li> </Li><Li> </Li></ul>
It looks weird, and the goal is to eliminate HTML whitespace from the root cause, so the default spacing is gone.
Method Three: Do not inline-block, with float
ul { list-style: none; width: 100%;} Li { float: left; width: 25%; height: 100px;}
This method behaves normally under UC.
Method Four: Use the Box/flex layout
ul { list-style: none; display: -webkit-box;} Li { -webkit-box-flex: 1; height: 100px;}
This behavior, including UC, is normal. But after all,-webkit-box is old-fashioned and seems a bit behind. Then use the new Flex bar:
ul { Width : 100% ; List-style : none ; display : -webkit-flex ; display : flex ; -webkit-flex-direction : row ; Flex-direction : row ;} li {-webkit-flex-grow : 1 ; Flex-grow : 1 ; : 100px ;}
The results found that Andro UC is not, has been explicitly declared as a horizontal arrangement, UC or play vertical.
So you can use-webkit-box, or-webkit-box and Flex, which are all normal:
ul { width: 100%; List-style: none; display: -webkit-box; display: -webkit-flex; display: flex; -webkit-flex-direction: row; flex-direction: row;
}
li{ -webkit-box-flex: 1; -webkit-flex-grow: 1; flex-grow: 1; height: 100px;
}
Method Five: Table layout
ul { display: table; width: 100%;} Li { display: Table-cell; width: 25%; height: 100px;}
Method Six:
Absolute Positioning (=.=)
Summary: Use "font-size:0;" for parent elements The default spacing to eliminate Inline-block for child elements does not work and is not good for flex support. A compatible solution should be considered in the formal application.
Mobile end row and column layout