一、技术选型

二、搭建相关文件夹

三、设置视口标签以及引入初始化样式文件和js文件

四、body 样式

五、rem 适配方案二 body样式修改

index.css

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来做屏幕适配了

六、VScode px转换rem 插件 cssrem

6.1 安装 cssrem

6.2 设置html 字体大小基准值

  1. ctrl + 逗号 打开设置

  2. 找到扩展中的 cssrem 插件 进入 Root Font Size 修改

  3. 修改完成后 重启 VScode

七、search-content布局以及修改 flexble.js 默认html字体大小

index.html

<body>
<!-- 顶部部分 -->
<div class="search-content"></div>
</body>

index.css

.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设计稿来执行

@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;
}

八、search-content 内容制作

index.html

<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;
}

最新文章

  1. angular service provider
  2. Intellij Idea 编辑器使用之 安装、破解 版本15.0.1
  3. POJ2653判断直线是否相交
  4. ORACLE导入、导出命令使用方法
  5. 正则表达式匹配/data/misc/wifi/wpa_supplicant.conf的WiFi名称与密码
  6. @OneToMany---ManyToOne
  7. Ubuntu 14.04下翻译软件的安装与比较
  8. 笔直的水管 usaco 背包
  9. chrome浏览器扩展--QQ群查看器(1)
  10. 容易上手-类似ERP系统 简单特效
  11. NETSH WINSOCK RESET这个命令的意义和效果?
  12. 怎样判断iOS App是通过哪种途径启动的?
  13. eclipse 工具栏修改
  14. .babelrc配置(webpack)
  15. LeetCode算法题-Single Number(Java实现)
  16. 绕过Snoopy的记录功能
  17. java的时间处理
  18. Chinese Seals
  19. JDK环境变量的配置说明
  20. RHEL6 - 图形化设置IP

热门文章

  1. yaml使用
  2. miniconda使用
  3. SpringMVC&amp;Maven进阶
  4. NC-UClient下载安装应用详解
  5. 【云原生 · Docker】Docker简介及基本组件
  6. win11如何双屏幕(1台主机2块显示器)
  7. C++ 之 宏定义
  8. 【SQL进阶】【表默认值、自增、修改表列名、列顺序】Day02:表与索引操作
  9. 【Java SE进阶】Day08 File类、递归
  10. 【Hadoop学习】上:组成介绍、生态体系、环境准备、不同运行模式测试