html - 在 nuxt.js 中使用 width:100vw 时有额外的空白
问题描述
我正在我的 nuxt.js 中构建组件横幅。
我尝试了很多方法来解决这个问题,但仍然没有解决,我尝试在我的and标签中添加margin:0;
and ,但空白仍然存在。我在这个主题中尝试了另一个解决方案,关于using-100vw-and-vh-creates-extra-space-beyond-viewport-size-how-do-i-get-rid-of但是当我尝试它时结果仍然相同. 我也尝试过这个话题,关于100vw-causing-horizontal-overflow-but-only-if-more-than-one但没有运气。padding:0;
html
body
这是我的横幅组件:
<template>
<div id="paham-banner-career">
<div class="banner-container">
<h2>Let's See Where You Fit In</h2>
</div>
</div>
</template>
这是我的CSS:
<style lang="css" scoped>
#paham-banner-career{
font-family: "Nunito", sans-serif;
background-color: #3b73c5;
width: 100vw;
max-width: 100%;
}
#paham-banner-career .banner-container{
margin: 100px auto;
padding: 25px 0px;
text-align: center;
max-width: 1200px;
}
#paham-banner-career h2{
color: #ffffff;
font-size: 2.5em;
font-weight: bold;
}
</style>
有人可以救我来解决这个问题吗?
解决方案
尝试添加box-sizing
<style lang="css" scoped>
*{box-sizing: border-box;}
#paham-banner-career{
font-family: "Nunito", sans-serif;
background-color: #3b73c5;
width: 100vw;
max-width: 100%;
}
#paham-banner-career .banner-container{
margin: 100px auto;
padding: 25px 0px;
text-align: center;
max-width: 1200px;
}
#paham-banner-career h2{
color: #ffffff;
font-size: 2.5em;
font-weight: bold;
}
</style>
推荐阅读
- java - 在 Java 中使用 for 循环将元素从一个列表传输到另一个列表
- asp.net-mvc - Telerik MVC 网格相关
- swift - Xcode NSStatusBar 项目未出现
- java - 电子商务网络服务和支付网关之间的通信
- python - Visual Studio 代码调试器不显示绘图
- r - 正则表达式删除以字符串开头的单词
- java - setText doesn't work properly if the string starts with a negative sign
- javascript - 将 RestSharp Reqest AddParameter 转换为 POST 请求的 JavaScript 数据
- assembly - AVR 字节存储
- multithreading - 多核架构 VS 多线程