html - 为什么我的网站的 CSS 代码在 bootstrap studio 中没有响应?
问题描述
我在 Bootstrap Studio 中使用 HTML 和 CSS 制作了我的网站
当在移动设备上查看时,我尝试使用@media 来放大一个盒子:
.container_a {
text-align: left;
padding: 0px;
padding-left: 0px;
margin: 0px;
padding-right: 0px;
color: #fafafa;
background: #000000;
padding-bottom: 0px;
border: 2.4px solid #999;
border-top-left-radius: 7px;
border-top-right-radius: 7px;
height: 33%;
width: 30%;
}
.container_a {
position: absolute;
top: 50%;
left: 50%;
-moz-transform: translateX(-50%) translateY(-50%);
-webkit-transform: translateX(-50%) translateY(-50%);
transform: translateX(-50%) translateY(-50%);
}
@media (min-width: 768px) {
container_a {
text-align: left;
padding: 0px;
padding-left: 0px;
margin: 0px;
padding-right: 0px;
border-radius: 10 px;
color: #fafafa;
background: #000000;
padding-bottom: 0px;
border: 2.4px solid #999;
border-top-left-radius: 7px;
border-top-right-radius: 7px;
height: 33%;
width: 30%;
}
}
@media (min-width: 320px) and (max-width: 768px) {
container_a {
width: 80%;
height: 35%;
}
}
为什么它不起作用?
解决方案
这不能回答您的问题,因为它与拼写错误相关并且将被关闭,但是您确实可以将 CSS 减少到更易于管理的内容,因为您有一堆冗余代码:
.container_a {
text-align: left;
padding: 0;
margin: 0;
color: #fafafa;
background: #000000;
border: 2.4px solid #999;
/* Shorthand for border-radius */
border-radius: 7px 7px 0 0;
position: absolute;
top: 50%;
left: 50%;
/* combine into the translate shorthand */
transform: translate(-50%, -50%);
/* Put your mobile styles here */
width: 80%;
height: 35%;
}
@media (min-width: 768px) {
.container_a {
/* Only add the properties that change */
height: 33%;
width: 30%;
}
}
推荐阅读
- keras - 在 keras 中连接多个 CNN 模型
- scala - 带有函数式编程的 ConcurrentHashMap。暂停 unsafeRun 安全吗?
- javascript - 替换Javascript中的多个单词
- javascript - 仅在具有相同类名的特定项目上运行 Javascript 函数
- javascript - 如何使用 Node repl 读取环境变量
- angularjs - 将 IFormFile 更改为 IList
并发送 $http.post 请求。AngularJS、ASP.NET 核心 - java - 应用程序序列化错误,java.io.NotSerializableException:
- python - Python numpy 索引不一致
- python - 一切都归结为 Python 中的内置对象吗?
- excel - Excel VBA-Mkdir 返回找不到路径