Using CSS min-height: 100vh will ensure that the container has enough height to fill the entire viewport

Utilizing min-height: 100vh; in my inner call to action div placed on top of a background video has been mostly successful. However, I've encountered an issue where using 100vh with the absolutely positioned video seems to introduce an unwanted margin to the section.

Is there a way to maintain 100vh on the section without the additional margin? I've experimented with calc but it proves to be problematic with responsive design and mobile devices.

CSS

...
  .video-wrapper {
    position: absolute;
    top: 0;
    left: 0;
    bottom: 0;
    right: 0;

    .video-background {
      object-fit: cover;
      object-position: center center;
      width: 100%;
      height: 100%;
    }
  }

  .content-wrapper {
    @include media-breakpoint-up(xs) {
      display: flex;
      flex-direction: column;
      min-height: 100%;
      padding: 0;
      margin: 0;
    }
  }
...

.section-call-to-action {
  @include media-breakpoint-up(xs) {
    min-height: 100vh;
    padding: 0;
    margin: 0;

    .row {
      margin: 0;
      padding: 0;
    }
  }
...

HTML

<div class="video-wrapper">
  <video autoplay="" class="video-background" loop="" muted="" playsinline="">
    <source src="..." type="video/mp4">
  </video>
</div>
<main class="container-fluid content-wrapper">
  <section class="container-fluid d-flex flex-column flex-fill justify-content-center section-call-to-action">

  </section>
  <section class="container-fluid d-flex flex-column section-venn-wrapper">

  </section>
  <section class="container-fluid section-robot-friends">

  </section>
</main>

https://i.sstatic.net/30xIa.png

UPDATE

  1. I attempted to use min-height: calc(100vh - 5rem); and it worked in Chrome on desktop but not Safari on iOS.
  2. I came across the https://github.com/Hiswe/vh-check library, but I am aiming to solve this issue using only CSS.
  3. I also tested out iOS CSS but it did not yield successful results on iPads.
  @supports (-webkit-overflow-scrolling: touch) {
    min-height: calc(100vh - 200px);
  }

Answer №1

If you happen to stumble upon this and have a better solution in mind, I am open to suggestions.

I have implemented JavaScript to detect if the user is using an iOS device...

export default () => {
  const $sectionCallToAction = $('.section-call-to-action');
  const $iOS = navigator.userAgent.match(/Mac/) && navigator.maxTouchPoints && navigator.maxTouchPoints > 2;

    if ($iOS) {
    $sectionCallToAction.addClass('section-call-to-action-ios')
    }
};

This adds the specified class to the element...

.section-call-to-action-ios {
  min-height: 100vh !important;
  padding: 200px 0 0 0 !important;
  margin: -200px 0 0 0 !important;
}

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

What is the process for creating custom styles for MUIV5 components?

I have incorporated Mui v5 components into my project and currently I am utilizing sx props to style all the MUI components. However, it is becoming cumbersome to add sx in every line for each component. Therefore, I am seeking alternative methods for styl ...

Inserting JQuery Selector from a .js file into a .php file at the beginning

Incorporated in my project is a jquery plugin for a slider, which includes the code snippet below for handling 'next and prev' buttons. $(selector).prepend('\ <ul class="mk-nav-controls">\ <li>& ...

retrieve the value of a textarea element from an HTML table

Is there a way to extract data from a nested table's textarea using the row index? I attempted the following code snippet but it did not work. var note = document.getElementById($index).cells[3]; var y = document.getElementsByTagName("textarea").valu ...

Achieving Vertical Alignment of Content in Bootstrap 5

I've experimented with different approaches based on search results, StackOverflow suggestions, and examining existing code snippets. Here is the snippet of code I am working with: <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/<a ...

Multiple instances of the anchor tag are being inserted

Why is the anchor tag I specified in my code appearing multiple times when viewed in the browser? How can I fix this issue? <a href="{{ route('candidate.company.view', $company->id) }}" class="block no-overflow"> <div class="row ...

The full width of the div exceeds the parent's width, resulting in the box size being ineffective

I'm experiencing an issue where my cover is wider than my element and content. It seems to be covering the gunter, but I've tried using background-clip: content-box; and box-sizing: border-box;, which haven't resolved the problem. I also wan ...

retrieving dynamic data from an HTML form to JavaScript

Currently, I am dynamically adding elements using JavaScript. The count is defined and increases by one. <span style="margin-left:10px;">File Type : <select name="select_type_'+count+'" > <option value="select">Select</optio ...

Incorporate audio playback on image click using JavaScript, with the feature to automatically pause the playback if multiple images are playing simultaneously

<img class="cl" src="photo/198.jpg"/></br> <audio class="cs" controls> <source src="audio/198 banu nagamothu.mp3" type="audio/mpeg"> </audio> I prefer not to have audio controls initially, but when the image i ...

Move your cursor over the image to activate the effect, then hover over it again to make the effect disappear

Looking to enhance my images with hover effects. Currently, all the images are in grayscale and I'd like to change that so that when you hover over an image, it reverts to full color and remains that way until hovered over again. I've noticed so ...

Access a webpage in an html document using URL variables

In the process of developing an MVC web app without utilizing any MVC framework, I have created an index.html file with a section that dynamically loads all the views as needed by the user. However, I encountered an issue where direct URLs such as www.foo. ...

How to link a sandbox file in HTML with an iPhone

Looking to create an HTML application specifically for the iPad, I am interested in developing a background process using Objective-C that will handle the downloading of images and data. The goal is to be able to access these resources from within an HTML ...

The AJAX success function is operational, yet the file does not execute

As a newcomer to StackOverflow and web development, I am pressed for time with this assignment, so please bear with me if I struggle with understanding web development terminologies. My current challenge involves calling another php file through ajax in my ...

How do I hide a dropdown menu when the selector's value changes in iOS6?

I'm currently developing a hybrid application using Worklight. When I tap on a select control, a native dropdown appears. However, when I choose an option and the onchange event is triggered, the dropdown doesn't disappear unless I tap on the do ...

Troublesome alignment with bootstrap grid system

I require some assistance with the following: https://i.sstatic.net/vK9zmm.png Specifically, I need help regarding the structure shown below: <div class="row"><div class="col-md-4"> <a class="individ" href="index.p ...

concise stylus CSS selector

Is there a way to condense these stylus selectors for a cleaner look? #map > div.mapboxgl-control-container > div.mapboxgl-ctrl-top-left > div:nth-child(1) > button #map > div.mapboxgl-control-container > div.mapboxgl-ctrl-top-left > ...

Creating uniform-sized flex items with varying image sizes

When setting flex: 1 1 0 on flex items, it does not work as expected especially when the flex items contain images of varying sizes. In this scenario, the flex-item containing the image ends up becoming significantly wider than the others. Below is the H ...

Guide to binding input type= 'email' in Knockout.js

My project utilizes KnockoutJS with MVC. I am seeking assistance on determining whether an emailId is valid or invalid. Based on this validation, I need to dynamically enable/disable a button and set an error title for the corresponding textbox. Below is ...

Tips for designing websites using HTML and CSS

current result: https://i.sstatic.net/eXLPv.png desired output: https://i.sstatic.net/vgl6z.png I am aiming to center the text. add image description here add image description here ...

When you scroll through the page, white blocks suddenly appear

After completing a website, I noticed some white blocks appearing when scrolling. You can view the site here. This issue occurs on both mobile and desktop devices during the initial load only. Could this indicate that the page has not fully loaded yet? If ...

Achieve a scrolling effect for just a specific section of an HTML page

Hey there! I'm currently working on adding scrolling text along the side of a webpage for a specific section. My goal is to have three different sections, each with text that stops scrolling when you reach it and then transitions to the next section o ...