html - 如何根据css中的网页修复背景?
问题描述
我将半径背景设置为固定宽度和高度,但是当我当时缩小时,它只反映内容而不反映在背景上。我该如何解决?
当我缩小网页背景保持不变时,它不会改变
这是我的CSS代码: -
.main {
overflow: hidden;
}
.bg {
width:100%;
height:40vw;
border-bottom-left-radius: 80%;
border-bottom-right-radius: 80%;
background-color: #f0f5f5;
}
这是我的html代码:-
<div class="main">
<div class="bg">
<div class="container">
<div class="row">
<div class="col-md-6">
<h1>Join Pragra!</h1>
<p>Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book.</p>
<button class="btn">Contact us!</button>
</div>
<div class="col-md-6">
<img src="/assets/images/faq-banner.png">
</div>
</div>
</div>
</div>
</div>
解决方案
原因是您将高度设置为 40vh(视口高度),因此无论您放大还是加宽,它仍然具有 40vh(浏览器窗口高度的 40%)。所以解决方案很简单:只需将值设置为固定数字,例如:
.bg {
height: 500px;
}
推荐阅读
- javascript - 状态 204:response.json() - 捕获 SyntaxError:在 manageRequest 处 JSON 输入意外结束
- powerbi - REMOVEFILTERS 没有达到我在 Power BI 中的预期
- android - 初始化后如何获取片段的宽度/高度
- python - Python TKinter 进度条标签未正确运行
- html - 即使我的文件在同一目录中,如何应用 CSS?
- javascript - NCC / TS-NODE 中的奇怪错误阻止构建 TypeScript 项目
- typescript - 注意局部变量不能变回null
- javascript - 使 Material UI Grid 项目的子项拉伸以适应父容器的剩余高度
- javascript - Fetch API:是否可以请求部分 html 页面(开头)
- azure - 是否可以在不知道总共有多少阶段的情况下在 Azure Pipelines 中运行“最后阶段”?