html - 当屏幕较小时,当我的弹性框进入垂直行时,它们的背景不会跟随它们
问题描述
好的,我的问题是,你看到它何时最大化,它是如何在弹性盒后面有背景的吗?现在,如果您最小化屏幕,因为它是响应式的,它将把它放在 2 行中,但是 flexboxes 的背景仅在第一行而不是在第 2/3 行,所以它不是在每个框的后面,这就是我的问题,如果有人可以修复和解释,将不胜感激, FIDDLE:https://jsfiddle.net/vu4eaw2t/
代码(检查 FIDDLE THO 代码就在此处,以便我可以发布此帖子):
<html>
<head>
<link rel="stylesheet" href="style.css">
<script src = "https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<script src="js/design.js"></script>
</head>
<body style="margin: 0;">
<div class="navmenu">
<ul style="list-style: none;" class="nav">
<li>Home</li>
<li>Purchase</li>
</ul>
<ul style="list-style: none;" class="navb">
<li><a>Account</a></li>
</ul>
</div>
<div class="features">
<div class="featuresbox"><p class="FeatureTitle">Lorem Ipsum</p><p class="FeatureDescription">Lorem ipsum</p></div>
<div class="featuresbox"></div>
<div class="featuresbox"></div>
<div class="featuresbox"></div>
</div>
</body>
</html>
CSS(再次检查小提琴不要使用这个小提琴会解释你我的问题,但请务必阅读我上面所说的):
body {
font-family: 'Arial Narrow Bold', sans-serif;
background-color: rgba(84, 111, 219, 0.959);;
margin-bottom: 15px;
}
.navmenu {
width: 100%;
display: flex;
background-color: rgb(28, 109, 231);
justify-content: space-between;
}
.navb {
margin-right: 24px;
}
.navmenu > ul > li {
float: left;
color: rgb(255,255,255);
font-size: 18px;
margin-right: 50px;
}
.navmenu > ul > li:hover {
transform: scale(1.03);
color: rgb(119, 151, 240);
transition: 0.4s;
}
.navmenu > ul > li:not(:hover) {
transform: scale(1);
color: rgb(255,255,255);
transition: 0.4s;
}
.features {
width: 100%;
height: fit-content;
margin-top: 50px;
background-color: rgba(75, 105, 221, 0.651);
display: flex;
flex-wrap: wrap;
justify-content: center;
}
.featuresbox {
height: 250px;
width: 270px;
border-radius: 4px;
background-color: rgba(45, 81, 224, 0.651);
float: left;
margin: 25px;
color: rgb(255,255,255);
}
.FeatureTitle {
font-size: 25px;
text-align: center;
}
.FeatureDescription {
text-align: center;
margin-left: 6px;
margin-right: 6px;
}
@media screen and (max-width: 950px) {
.navmenu > ul > li {
font-size: 15px;
margin-right: 33px;
}
.features {
height: 300px;
}
}
解决方案
那里有一个小错误,你只是features
用这个媒体查询限制了 div 的高度:
@media screen and (max-width: 950px) {
.features {
height: 300px;
}
}
因此,每当屏幕达到950px
或降低features
div 高度时300px
,它就不会覆盖那里的所有框。
要修复它,您所要做的就是删除上述媒体查询样式,然后就可以了。
推荐阅读
- php - 将 3 个表的结果与 MAX(date) 结合起来
- python - 将 csv 文件中的数据插入 mysql 表
- django - “GenericRelatedObjectManager”不是 JSON 可序列化的
- c# - 线程安全阅读指导两次
- jenkins - npm 错误!EPERM:不允许操作,scandir
- python - 有没有办法根据一个字段(比如说field3)从2个文件(A anb)中获取唯一行,其中A在重复的情况下优先?
- matrix - 方阵的踪迹?
- android - 为什么openGL会阻止UI?
- c++ - 相互依赖的静态库
- spring-integration - setOnFailureExpression 不适用于#root 和#exception