index.css
javascript
body { min-width: 320px; max-width: 750px; /* flexible 给咱们划分了 10 等份 */ width: 10rem; margin: 0 auto; line-height: 1.5; font-family: Arial, Helvetica; background: #f2f2f2; }
再也不须要common.js来作屏幕适配了css
ctrl + 逗号
打开设置
html
找到扩展中的 cssrem 插件 进入 Root Font Size
修改
java
修改完成后 重启 VScode布局
index.html
字体
<body> <!-- 顶部部分 --> <div class="search-content"></div> </body>
index.css
flex
.search-content { position: fixed; top: 0; left: 50%; transform: translateX(-50%); width: 10rem; height: 1.173333rem; background-color: #FFC001; }
咱们发现,因为 flexble.js中的影响,页面的效果实际上是根据咱们当前屏幕的大小来断定的,并非咱们想要的效果,因此咱们须要修改 flexble.js 默认html字体大小
若是咱们的屏幕超过了 750px 那么咱们就按照 750设计稿来执行url
@media screen and (min-width: 750px) { html { font-size: 75px; } }
咱们发现页面仍是没有达到咱们想要的效果,缘由是权重不够
为 html 的字体大小设置 !important
插件
@media screen and (min-width: 750px) { html { font-size: 75px!important; } } .search-content { position: fixed; top: 0; left: 50%; transform: translateX(-50%); width: 10rem; height: 1.173333rem; background-color: #FFC001; }
index.html
ssr
<body> <div class="search-content"> <a href="#" class="classify"></a> <div class="search"> <form action=""> <input type="search" value="新人专享礼"> </form> </div> <a href="#" class="login">登陆</a> </div> </body>
index.css
a { text-decoration: none; font-size: .333333rem; } .classify { width: .586667rem; height: .933333rem; margin: .146667rem .333333rem .133333rem; background: url(../images/classify.png) no-repeat; background-size: .586667rem .933333rem; } .search { flex: 1; } .search input { outline: none; border: 0; width: 100%; height: .88rem; font-size: .333333rem; background-color: #FFF2CC; margin-top: .133333rem; border-radius: .44rem; color: #757575; padding-left: .733333rem; } .login { width: 1rem; height: .933333rem; margin: .133333rem; color: #fff; text-align: center; line-height: .933333rem; font-size: .333333rem; }