Bootstrap 5媒体查询与响应类不匹配
我使用 bootstrap 5 来实现这样的简单布局
.section1 {
background: red;
}
@media all and (max-width: 575px) {
.section1 {
background: green !important;
}
}
<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet"/>
<div class="container">
<div class="container1 d-flex d-sm-block">
<div class="text-white section1">
Section 1
</div>
<div class="bg-light text-dark section2">
Section 2
</div>
</div>
<div>
当缩小屏幕尺寸时,我希望 section1
的背景变为绿色,同时 container1
的 display 属性更改为显示 flex
>
目前有 3 个不同的状态..
我哪里出错了?
I am using bootstrap 5 for a simple layout like this
.section1 {
background: red;
}
@media all and (max-width: 575px) {
.section1 {
background: green !important;
}
}
<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet"/>
<div class="container">
<div class="container1 d-flex d-sm-block">
<div class="text-white section1">
Section 1
</div>
<div class="bg-light text-dark section2">
Section 2
</div>
</div>
<div>
When making the screensize smaller, I want the background of section1
to change to green at the same time that the display property of container1
changes to display flex
Currently there are 3 different states..
Where am I going wrong?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您应该将“container1”类更改为:
至
并将媒体最大宽度更改为
max-width: 1024px
you should change "container1" class from :
to
and change media max width to
max-width: 1024px