Home > Article > Web Front-end > Xiaomi Mall Responsive Learning_html/css_WEB-ITnose
What I have always longed for is Taobao’s mobile webpage, which is truly responsive through rem, but I always feel that it is quite different from the original approach on the PC. Maybe I can’t understand it. Over the weekend, I accidentally discovered that Xiaomi’s mobile webpage is also written in em mode. Looking at the source code, I found that this is the responsive wap webpage I am pursuing. Record the learning~
Website: http://m.mi.com
Set the base font size through the global body
body { font-size: 20px;}@media only screen and (max-width: 710px) and (min-width: 640px)body { font-size: 17.77778px;}
Global style settings
@font-face { font-family: iconfont; src: url(/static/fonts/iconfont_2337a86.eot?9owfml); src: url(/static/fonts/iconfont_2337a86.eot?#iefix9owfml) format("embedded-opentype"),url(/static/fonts/iconfont_53935e1.woff?9owfml) format("woff"),url(/static/fonts/iconfont_bfbfeef.ttf?9owfml) format("truetype"),url(/static/fonts/iconfont_7a400bd.svg?9owfml#icomoon) format("svg"); font-weight: 400; font-style: normal}[class^=icon-], [class*=" icon-"], .iconfont { font-family: iconfont!important; speak: none; font-style: normal; font-weight: 400; font-variant: normal; text-transform: none; line-height: 1; -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale;}
Add iconfont element
.page-index .nav-index li a .icon:before { font-size: 4em; color: #5c6066; line-height: 1.375em;}
.icon-huafeichongzhi:before { content: "\e608";}
Other settings
.page-index .nav-index li a .icon { display: block; margin: 0 auto .5em; width: 5em; height: 5em; -webkit-background-size: 5em 5em; -moz-background-size: 5em 5em; -ms-background-size: 5em 5em; -o-background-size: 5em 5em; background-size: 5em 5em;}
The image is adaptive based on the em width and height of the parent
.imgurl img { width: 100%;}li, img, label, input { vertical-align: middle;}
Vertically centered content and horizontally centered content
div#DemoArea { display: box; box-align: start; -moz-box-align: start; -webkit-box-align: start; box-align: start;}
div#DemoArea { display: box; box-align: start; -moz-box-pack:center; -webkit-box-pack:center; box-pack:center;}