html - 响应式设计制作
问题描述
我正在为桌面版和移动版进行设计,但我被按钮的位置困住了,我为桌面版的按钮 ID“三、四、五、六、七、八”编写了定位 css,并编写了另一个在“@media only screen and (max-width: 600px){}”中为所有移动版本定位 CSS,但问题是当我打开桌面版本时,它需要移动版本的定位 CSS。我应该怎么做才能解决这个问题。
i have tried the important keyword but it shows the same behavior.
#three,#four{
background-color:blue;
position: relative ;
left: 380px ;
top:0px ss;
}
#five,#six{
background-color: #FFA500;
position: relative;
left: 0px;
top: 0px;
}
#seven,#eight{
background-color: #4c4c4c;
position: relative;
left: 380px;
top: 0
}
@media only screen and (max-width: 600px){
#three{
position: relative;
left: 291px;
top: 137px;
}
#five{
position: relative;
left: 291px;
top: 141px;
}
#seven{
position: relative;
left: 289px;
top: 136px;
}
#two{
position: relative;
left: 291px;
top: 94px;
}
#four{
position: relative;
left: 293px;
top: 94px;
}
#six{
position: relative;
left: 296px;
top: 94px;
}
#eight{
position: relative;
left: 295px;
top: 94px;
}
}
this is the code.
解决方案
我为响应式设计 Web 的方式是使用移动优先的工作流程。这意味着您没有媒体查询的默认样式适用于移动设备。
然后使用:
@media screen and (min-width: 768px) {
/* Only applies to bigger than 768px */
}
这种方法意味着如果您的 CSS 文件排序正确,移动设备位于顶部并向上移动,则不需要使用 !important。
推荐阅读
- c# - 如何从 C# 中的 Google Calendar API 中创建的事件中获取 HangoutLink?
- php - 如何在 laravel 中使用 ajax 调用从控制器加载数据以查看?
- amazon-web-services - AWS EC2 公共 DNS 和公共 IP 显示拒绝在浏览器上连接
- python - Python代码来计算2个邮政编码之间的距离?
- c - 我尝试编写一个使用函数查找 GCD 的程序。为什么这段代码不起作用?
- pycharm - 修复 PyCharm 的导航菜单
- sql - 如何在 Hive SQL 中搜索后跟 4 个数字的两个字符串
- c++ - 将 C++ 成员函数作为回调函数传递
- database - 如果我使用同一个数据库连接两个网站会发生什么?
- firebase - Firebase 云函数中的条件语句