You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何去除文本区域的白色背景(Bootstrap 5环境)

解决Bootstrap 5中文本区域白色背景覆盖背景图的问题

问题原因

你遇到的白色背景并非来自<main>元素,而是Bootstrap默认给<body>标签设置了background-color: #fff;,这个白色背景会覆盖<html>上的背景图,导致你给.main设置background-color: transparent;没有效果。

解决方案

给<body>添加透明背景样式即可:

body {
  background-color: transparent;
}

将这段代码加入你的CSS中,就能让<html>的背景图正常显示,同时文本区域保留在背景图上方。

完整修改后的CSS示例

* {
  padding: 0;
  margin: 0;
  font-family: "Roboto", sans-serif;
}

html {
  background: url(http://ndquiz.epizy.com/img/worldPersonalProject.png) no-repeat center fixed;
  background-size: cover;
}

/* 添加该行解决白色背景问题 */
body {
  background-color: transparent;
}

.btn-select {
  background-color: #008cba;
  border-radius: 10px;
  text-align: center;
}

.main {
  margin-top: 100px;
  background-color: transparent !important;
}

.big {
  font-size: 60px;
}

内容的提问来源于stack exchange,提问作者nd03

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.12 21:50:36