Generate several div containers that occupy the entire screen

I'm struggling to design a one-page website with full-screen divs, but I can't seem to make them truly full screen. This is my first time using Bootstrap for responsiveness, and I want the background video to remain fixed while the divs take up the entire viewport upon scrolling.

<!DOCTYPE html>
<html>
<head>
    <link rel="icon" href="imagens/logo_icone.png">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <link rel="stylesheet" href="css/bootstrap.min.css">
    <link rel="stylesheet" href="css/estilos.css">
    <title>Museu do Barro Preto</title>

</head>

<body>  
<div class="container-fluid">
                          <!--Video -->
<div class="row">
<div class="col-xs-12">
    <video class="video_bg" autoplay muted loop>
        <source src="video/prom.mp4" type="video/mp4">
        A extensão do ficheiro não é suportada pelo seu browser
    </video>
    </div>
      </div>
     <!--/Video -->

  <!--Barra de Navegação-->
    <div class="row">
    <header class="col-md-12">
        <nav class="navbar navbar-inverse navbar-fixed-top">
        <div class="container-fluid">
            <div class="navbar-header">
      <button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#myNavbar">
        <span class="icon-bar"></span>
        <span class="icon-bar"></span>
        <span class="icon-bar"></span> 
      </button>
      <a class="navbar-brand" href="#">WebSiteName</a>
    </div>
    <div class="collapse navbar-collapse" id="myNavbar">
          <ul class="nav navbar-nav navbar-right">
            <li><a href="#texto1">Quem Somos</a></li>
            <li><a href="">Onde Estamos</a></li>
            <li><a href="">Educação</a></li>
            <li><a href="">Video</a></li>
            <li><a href="">Exposições</a></li>
      </ul>
    </div>
    </div>
        </nav>
    </header>
</div>
<!--/Barra de Navegação-->

<div class="row pag1">
    <article class="col-md-8">
            ...

CSS

html,body {
  height:100%;
  margin:0;
}

html>body .pag1 {
  height:auto;
}
.video_bg { 
  position: fixed;
  top: 50%;
  left: 50%;
  min-width: 100%;
  min-height: 100%;
  width: auto;
  height: auto;
  z-index: -100;
  transform: translate(-50%, -50%);
}

 .borders {
    border: 1px solid black;
 }

 .documentario {
    width: 500px;
    height: 500px;
 }

 .pag1 {
    width: 100%;
    height: 100%;
    margin-top: 100%;
    background-color: #fff;
    overflow: hidden;
    position: relative;
 }

 .pag1 img {
    width: 400px;
    height: 400px;
 }

Answer №1

To optimize your divs, consider using the vh style.

Try setting a maximum height for your div like this:

div {max-height:100vh;} // This will restrict the div's height to 100 vertical height units, equivalent to full screen size.

http://www.example.com/css_units_guide

Answer №2

If you're looking for a solution that works well across different browsers, consider using the vh unit with a fallback option. In our experience, Bootstrap may not be the best choice for projects requiring full-screen elements. Instead, we recommend sizing each element using 100vh within li tags, with fallbacks to pixel units set by JavaScript. This setup can be complex at first but saves time in the long run and ensures accessibility.

For example:

  1. 'Page' content here.
  2. 'Page'content here.

Don't forget to check out Modernizr for additional support:

It's also important to consider the compatibility of video formats for full-screen display. And remember, aspect ratios can vary between videos and screens!

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

using CSS to create responsive designs with multiple divs

After spending hours searching, I am still struggling to get two divs to sit next to each other at 50% width each, with a third div below that spans 100% width. The challenge is to make the layout responsive, so that when the screen size is reduced to arou ...

Integrating HTML into a C# Windows form application

Just diving into the world of online shopping and came across an e-commerce cart that I'd like to integrate into my own website. The platform provided me with a HTML code snippet for embedding, which is great. However, I'm wondering if it's ...

What is the method for embedding the creation date of a page within a paragraph on Wagtail?

Whenever a page is created in the admin panel of Wagtail, it automatically displays how much time has elapsed since its creation. https://i.stack.imgur.com/6InSV.png I am looking to include the timestamp of the page's creation within a paragraph in ...

What is the process for developing multiple screens or views in PhoneGap?

Currently working on a reading app and decided to give phoneGap a shot for the first time. I'm pretty proficient in HTML, CSS, and JS, but not very familiar with xCode. In this app, I plan to have a button on the home screen that redirects users to an ...

creating divs inside a parent div with varying heights and using auto margins

Can anyone help me with this code snippet? <div style="position: relative;"> /***main***/ <div style="top:0"> /*****Content1****/ </div> <div> /*****Content2****/ </div> <div> ...

Issues with AngularJS UI Router functionality are being experienced specifically on localhost

What is causing the discrepancy in UI-Router functionality between JSFiddle and localhost? The localhost link is http://127.0.0.1:54046/preview/app/index.html. Have I overlooked something crucial here? There are no visible JS errors present in the console. ...

What steps can I take to create a slideshow with dynamic animations?

I am trying to create a unique category display by turning it into a slider. When the user clicks on any category, I want it to move to the left and become larger. To see an example of how the sliding effect works, check out this link: slideshow https://i ...

Ensure the sum is recalculated whenever the input changes by using the jQuery change event

I am creating a system that requires the total values of multiple inputs to not exceed 100. I have successfully implemented this functionality, but now I need a way to automatically adjust the total if changing one input causes it to drop below 100. Here& ...

Difficulty with the Jquery <span> tag on Mozilla 3.6.1

I am currently utilizing jQuery.post to display some data retrieved from a servlet. <div class="Label"> <span id="result" >Click on Check.</span> </div> <script> $(document).ready(function() { $("a").c ...

How to Keep PHP Include Visible within the div using Bootstrap 4

I utilized PHP include to add the information inside the modals for the albums, but it is not hidden as specified in the div class where it is included. You can check out the music page on . However, here is the code snippet for the music page where I in ...

Footer alignment issue when using react-full-page is causing it to not lineup at the bottom of the page

Currently, I have integrated the react-full-page package into my project. However, after adding the Footer to the routes, I noticed that the footer is only visible in the second section of the page and does not appear at the bottom as expected. If you wan ...

Adding a div with a canvas element is malfunctioning

I've been experimenting with using canvg to convert an SVG within a div into a canvas. So far, the conversion is working fine but when I try to copy the innerHTML of the div to another div, it's not functioning properly. The canvas is being gener ...

Tips for creating a clickable popover within a window that remains open but can be closed with an outside click

Is there a way to ensure that my popover window remains clickable inside its own area without closing, but automatically closes when clicked outside of the window? This is the code I am currently using, which is triggered by a button click: if (response. ...

What is the best method for implementing a "night mode" feature using CSS?

I have a vision for a website that offers both a 'day' and 'night mode', providing users with a light and dark version of the site. However, I'm struggling to find the best way to achieve this. Initially, I attempted creating two ...

Redefining the colors of an SVG when it is a CSS background image in code

I currently have an SVG icon encoded within my CSS file. I'm looking to change the color of this icon when a user hovers over it without creating a duplicate icon in a different color. Here's a snippet from my CSS file: background-image: url("d ...

Elevate your web design by transitioning from Bootstrap 4 to Bootstrap 5

Should I upgrade a large project from Bootstrap 4 to version 5? Will it require extensive changes in each file? After updating my project, many components have stopped working: Dropdowns Accordions and more Is this a common issue experienced by everyo ...

Including a pointer image in an image map

Here is a CSS image map setup that I've been using: HTML: <div style="display:block; width:791px; height:1022px; background:url(images/image.jpg); position:relative; margin:2px auto 2px auto;"> <div><a class="imagemaplink" style="left: ...

Effortlessly sending multiple forms on a single page via POST in Express JS without the need for page refresh

I am creating a new application using ExpressJS and I want to include the following HTML code in a jade file. On one of my pages, I have 4 form buttons: <div class="dog"> <div class="dog_wrapper clearfix"> <div cla ...

Ordering columns inside columns with responsive design in Bootstrap 5

Could the layout be rearranged for md+ devices to this configuration on xs, sm devices? <head> <link href="https://cdn.jsdelivr.net/npm/<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="294b46465d5a5d5d5b4859691c07 ...

Arrange the assortment of varying sized badges in a straight line

I have a variety of badges representing users. Some users have images displayed as blocks while others are represented by text inline. https://i.sstatic.net/BtDgo.png Within the container, we have the following structure: <div class="align-self-cente ...