What is the reason behind Chrome's fullscreen mode turning the background black?

I created a webpage with full-screen functionality and made sure to use the correct CSS properties to ensure that my gradient background covers the entire screen perfectly. However, I encountered an issue when clicking the full-screen button in Chrome - the background turns black instead of remaining as the gradient. I've searched everywhere but can't seem to find what's causing this issue. Interestingly, it seems to work fine on iPadOS. You can find the CSS code below and access the rest of the code on my GitHub repo.

Any assistance on this matter would be highly appreciated!

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;
}

Answer №1

There is a minor error in your JavaScript code for fullscreen mode.

body.requestFullscreen();

By using this code, you are attempting to make the body element go into fullscreen mode instead of the entire page.

Instead, you should use the following code:

document.documentElement.requestFullscreen()

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Angular unable to register service worker

Looking to implement push notifications in my Angular app using vanilla JavaScript instead of the Angular service worker or @angular/pwa. In angular.json, I've specified the path to the js file under the script option. However, when the service worke ...

Fixing the filter button: A step-by-step guide

I'm new to html and spring boot, and I'm currently working on filtering and searching for books in a list based on the author, description, etc. However, it seems that my button isn't functioning properly. Can someone please assist me with t ...

Tips for preventing my component from being duplicated during the development process

I found a helpful guide on creating a JavaScript calendar in React that I am currently following. After implementing the code, I successfully have a functional calendar UI as shown below: // https://medium.com/@nitinpatel_20236/challenge-of-building-a-cal ...

React is encountering a problem with loading the image source and it is

<img src="play.jpg" alt="play"></img> This code works fine in standard HTML, but I'm having trouble getting it to work in React. Is adding it as a background the only solution? ...

Finding the correct index number for the active class - a step-by-step guide

I am currently troubleshooting an issue with my demo. I am having trouble retrieving the correct index number of .carousel-item.active. Even when the second slide is displayed, I continue to receive the index of the first slide. var totalItems = $(&apos ...

Here is a guide on how to specify function selection values for a total order. By default, the selection will have predetermined values, and upon clicking the sum button,

<tr id=""> <th> <select id="selection" onchange="myFunction()"> <option id="0" value="0">None</option> <option id="1" value="4.00">Women Suit</option> <option id="2" value="10.00">Dres ...

Tips for customizing the scrollbar design in iOS Safari

Task at hand requires me to customize the scrollbar style on my HTML page. Below is the CSS code I am using: .txt_Content::-webkit-scrollbar { width:5px; border-radius:4px; } .txt_Content::-webkit-scrollbar-button { display: none; } .txt_Co ...

Choose a Vue filter according to the variable selected

My Current Table Dilemma Creating a table from a 2D array in Vue2 has been successful for me, as I've managed to display all the values correctly. However, I am facing issues with formatting. The template code is structured like this: <table> ...

The positioning problem arising from using a Vuetify select dropdown within a datatable

Vuetify datatable is being used with 20 columns, functioning properly. To view all the columns, horizontal scrolling is available. Filters are needed for each column in the header, achieved using v-slot:header. An issue arises when clicking on the select ...

Display the option to "Delete" the link only when there are multiple images in my image collection

I am using jQuery and Ajax to remove banner images from my website. However, I want to make sure that if there is only one image left, it cannot be deleted. Each image in the list has a corresponding delete link: echo '<a class="delete j_bannerd ...

What is the best way to eliminate the nesting in this ternary operation?

Object.values(filter).filter(item => (Array.isArray(item) && item.length > 0) || (typeof item === "boolean" && item === true) || (item !== null)).length ? filterIcon : unFilledIcon In this code, I aim to simplify the nested ternary operator and ...

Exploring the world of web programming

Looking for top-notch resources to learn about JavaScript, AJAX, CodeIgniter and Smarty. Any recommendations? ...

Is there a way to dynamically adjust the height of a DIV block?

I have a situation where I need the height of one div to automatically adjust based on changes in the height of another div. var height = jQuery('#leftcol').height(); height += 20; jQuery('.rightcol-botbg').height(height); Unfortun ...

Learn how to iterate over a JSON object using TypeScript in Angular5 to generate an array of objects

Here is a sample JSON code that includes an array "Customers" with objects and arrays nested inside: This is my JSON code snippet: { "Customers": [ { "customerData": { "secondLastName": "Apale", "firstLastName": "Lara", ...

Troubleshooting the Hover Effect of Buttons in Next.js when Using Tailwind CSS for Dynamic Color Changes

Encountering a problem with button hover functionality in a Next.js component using Tailwind CSS. The objective is to alter the button's background color dynamically on hover based on a color value stored in the component's state. This code func ...

Arrange the grid in a pleasing manner

I'm really struggling with this issue. In my current setup, I have a Grid container that holds two separate grids - one for a textfield and another for a checkbox. Unfortunately, I can't seem to get them to align properly. <Grid container& ...

What is the proper way to add process.env.PORT to the script declarations string within my package.json file?

I am facing an issue while trying to upload my file on Heroku that requires including the PORT specification. Unlike my previous projects, this project consists of only html, js, and css files instead of an index.js file. To run it, I am using "live-server ...

Is it possible to independently verify the results of promises within a $.when(...) function without regard to the overall outcome?

Take a look at this example: $.when(a1, a2, a3, a4, .....) .done(function (){alert('done')}) .fail(function (){alert('fail')}); If all promises from a1 to ax were successful, I can manage and handle all the data within t ...

Oops! Looks like we couldn't locate the request token in the session when attempting to access the Twitter API

Every time I attempt to connect to the Twitter API using Passport OAuth, an issue arises that redirects me to an error page displaying this message: Error: Failed to locate request token in session at SessionStore.get (/Users/youcefchergui/Work/ESP/socialb ...

Obtain a pointer to the timestamp within a embedded Kibana chart on an HTML webpage

The image at the specified link shows a black box labeled @timestamp displaying date and time information. Unfortunately, viewing the image requires a reputation of 10. Link to image: https://www.elastic.co/assets/bltde09cbafb09b7f08/Screen-Shot-2014-09-3 ...