【问题标题】:Why does Chrome fullscreen make the background black? [closed]为什么Chrome全屏会使背景变黑? [关闭]
【发布时间】:2020-03-11 23:52:09
【问题描述】:

我构建了一个具有全屏功能的网页。我使用了所有正确的 CSS 属性来确保我的渐变背景完全覆盖屏幕,而且确实如此。但是,当我在 Chrome 中单击网站上的全屏按钮时,页面会进入全屏状态,但 背景变为黑色。我到处寻找,仍然找不到任何问题。 iPadOS 似乎运行良好。 CSS 如下,其余代码在我的GitHub repo 中。

非常感谢任何帮助!

CSS:

@import url('https://fonts.googleapis.com/css2?family=Sen:wght@700&display=swap');

* {
  margin: 0;
  padding: 0;
}

html {
  scroll-behavior: smooth;
}

body {
  padding-bottom: 50vh;
  background: -moz-linear-gradient(top, #19c9ff 0%, #d504f9 100%);
  background: -webkit-linear-gradient(top, #19c9ff 0%,#d504f9 100%);
  background: linear-gradient(to bottom, #19c9ff 0%,#d504f9 100%);
  background-repeat: no-repeat;
  background-size: contain;
  text-align: center;
  font-family: 'Sen', serif;
}

.nav {
  background-color: rgba(0, 0, 0, 0.5);
  padding: 10px;
  position: fixed;
  width: 100%;
}

.full {
  color: white;
  position: fixed;
  right: 20px;
  top: 12px;
  font-size: 1.34em;
}

.auto {
  color: white;
  position: fixed;
  left: 20px;
  top: 12px;
  font-size: 1.34em;
}

.logo {
  max-width: 200px;
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 50vw;
}

p {
  color: white;
}

#pis {
  margin-top: 33vh;
}

h1 {
  color: white;
}

.micah-box i {
  font-size: 2em !important;
  color: rgba(0, 0, 0, 0.25);
  transition: 0.3s;
}

.micah-box {
  position: fixed;
  bottom: 15px;
  left: 15px;
  transition: 0.35s;
}

.micah:hover {
  color: white;
}

.micah-box h2 {
  font-size: 0.8em;
  float: right;
  margin-left: 10px;
  background-color: rgba(0, 0, 0, 0.25);
  padding: 9px;
  border-radius: 3px;
  color: rgba(225, 225, 225, 0.3);
  transition: 0.3s;
}

.micah-box h2:hover {
  background-color: white;
  color: black;
}

【问题讨论】:

  • github页面设置好了吗?请提供直接链接,以便快速重现问题
  • @YakovL 你可以在我的网站上查看它,micahlindley.com/pi-day

标签: javascript html css google-chrome fullscreen


【解决方案1】:

您的全屏 Javascript 略有错误。

body.requestFullscreen();

您在这里所说的是全屏正文元素,而不是整页。

改为尝试->

document.documentElement.requestFullscreen()

【讨论】:

  • 哦,好吧!非常感谢!这确实更有意义。接受的答案!
猜你喜欢
  • 2023-03-26
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2013-04-16
  • 1970-01-01
  • 2014-12-19
  • 2012-03-29
相关资源
最近更新 更多