Fully responsive header designed for optimal experience at any screen height

I am facing issues with the header and cannot seem to find a solution. My goal is to make the header span 100% of the window screen height. I need a responsive header that adjusts to 100% height, and when resizing for a smaller viewport, nothing should show below the header. The header contains a nested div with a bootstrap carousel. Below are the links to my code snippets:

http://codepen.io/anon/pen/EgJmEj

https://jsfiddle.net/3oht91fg/

<body>

<header>
  <div class="container">
    <div class="logo">
      <a href="index.html">
      </a>
    </div>
  </div>

    <nav>
      <div class="container">
        <ul class="nav-bar">
          <li><a class="active-subpage" href="">Option test</a></li><!--
          --><li><a href="">Option test</a></li><!--
          --><li><a href="">Option test</a></li><!--
          --><li><a href="">Option test</a></li><!--
          --><li><a href="">Option test</a></li><!--
          --><li><a href="">Option test</a></li></ul>
      </div>
    </nav>

    <div class="slider">

      <div id="myCarousel" class="carousel slide">
  <ol class="carousel-indicators">
      <li data-target="#myCarousel" data-slide-to="0" class="" contenteditable="false"></li>
      <li data-target="#myCarousel" data-slide-to="1" class="active" contenteditable="false"></li>
      <li data-target="#myCarousel" data-slide-to="2" class="" contenteditable="false"></li>
  </ol>
  <div class="carousel-inner">
      <div class="item" style="">
            <img src="http://placehold.it/1920x1080">

          <div class="carousel-caption">
              <h4 class="">First Slide Title</h4>
              <p class="">
                 Description for First Slide, this First Slide.
              </p>
          </div>
      </div>
      <div class="item active">
            <img src="http://placehold.it/1920x1080">
          <div class="carousel-caption">
              <h4 class="">Second Slide Title</h4>

              <p class="">
                 Description for Second Slide, this is Second Slide.
              </p>
          </div>
      </div>
      <div class="item" style="">
            <img src="http://placehold.it/1920x1080">
          <div class="carousel-caption">
              <h4 class="">Third Slide Title</h4>

                          <p class="">
                 Description for Third Slide, this is Third Slide.
              </p>
          </div>
      </div>
  </div>

  <a class="left carousel-control" href="#myCarousel" data-slide="prev">
      <span class="glyphicon glyphicon-chevron-left"></span>
  </a>

  <a class="right carousel-control" href="#myCarousel" data-slide="next">
      <span class="glyphicon glyphicon-chevron-right"></span>
  </a>


  </div>

    </div>



</header>
<main>

  <p>
  Lorem ipsum dolor sit amet, consectetur adipiscing elit. Maecenas a euismod libero. Phasellus elementum rutrum sapien et facilisis. Curabitur finibus eros laoreet ligula faucibus, quis interdum mauris efficitur. Aenean posuere iaculis sem, vitae pulvinar nibh aliquam dignissim. Nulla quis tristique dui. Duis luctus semper dignissim. Aenean tellus tellus, interdum at egestas nec, elementum ut tortor. Integer sodales nisi quam, ut rhoncus odio scelerisque ut. Morbi interdum leo a velit temp...
  </p>

</main>

<footer>
  <div class="container">
    <div class="left-footer col-md-4">
      <p>&copy; TEST</p>
    </div>

    <div class="right-footer col-md-8">

      <p>MADE BY ADER</p>

    </div>
  </div>
</footer>

Answer №1

This technique is compatible with CSS3 compliant browsers. Another option is to achieve the same result using positioning, but it may result in more unnecessary markup if your website's visitors are mostly using modern and updated browsers.

header {
    height:100vh;
}

With this method, 1vh represents 1% of the vertical height, so 50vh would be equivalent to 50%, and 100vh would be equal to 100%.

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

Rewriting URLs in Angular 2

I am a beginner in Angular 2 and I am currently working on a project that requires URL rewriting similar to that of ' '. In Zomato, when you select a city, the city name appears in the URL like ' ', and when you select a restaurant, t ...

Guide to incorporating a variable into the hyperlink function with Google Apps Script

Currently, I am utilizing Google Apps Script to create customized reports within Google Sheets. Within my spreadsheet, there is a column consisting of numbers that I would like to transform into hyperlinks. The URL for each hyperlink is mostly the same, wi ...

I am puzzled as to why this particular contact form is not functioning properly

I'm having trouble figuring out why my form isn't functioning properly. I receive a success message, but nothing is being delivered to my inbox. I even checked my spam folder to no avail. After waiting patiently for a few minutes, still no sign o ...

Tips for keeping your button fixed in place

I am encountering an issue where my button moves below the select dropdown list when I try to make a selection. Is there a way to keep the button in place even when the dropdown list from the select box is visible? For reference, here is the current outp ...

Steps to troubleshoot a scrollbar problem while applying flexbox in CSS

I'm currently working with a front-end framework that utilizes a flex layout. In my development of an admin page, I have included sections for the sidebar, header, and main. My objective is to ensure that the sidebar and the header + main sections fun ...

Having trouble with CSS webkit radial not working on iPad's Safari Mobile browser?

I'm feeling confused right now. I have this gradient code background-image: -webkit-radial-gradient(50% 65%, ellipse cover, #f2f2f4, #201935 55%); It's working on Safari when I change the User Agent to Mozilla/5.0 (iPhone; U; CPU iPhone OS 4_3 ...

Accessing data from another domain using JavaScript with Cross-Origin Resource Sharing (

After researching various CORS and JSON request discussions, I find myself puzzled as to why the first script functions correctly while the second one does not. I am eager to enhance my understanding of CORS, Javascript, XMLHTTPRequest2, and AJAX. The fol ...

How to create a non-clickable section within a linked div

Website: I am interested in linking just the triangle banner located at the top right corner of the page. The triangle image is actually a transparent rectangle with only the triangle portion filled in, so I want to ensure that only that particular sectio ...

Altering calendar dates using VBA for web scraping

Seeking assistance with creating a VBA program for automatically downloading historical stock data from a website. The code I have currently works for downloading data, but I'm facing challenges in changing the date using my code. You can view the co ...

Getting the value of a session variable in JavaScript from a PHP file

Despite the numerous inquiries on this topic, I am still struggling to comprehend it. Scenario: An image with a hyperlink When the image is clicked: Verify if session exists If session exists, open the link If session does not exist, display the login ...

Which web browsers are compatible with the input attribute "multiple"?

I am currently incorporating this particular plugin, and its file input does not support multiple file selection. To address this issue, I have added the 'multiple' attribute. However, I am curious if there are any browsers or other platforms (su ...

The Jquery Datatable fails to display the accurate number of rows based on the selections made in the dropdown

I am working on an ajax call that returns a table. In the success method, I am using $("#tableID").dataTable();. Although it shows paging and the number of rows in the dropdown, it is displaying all rows instead of only the number of rows selected in the d ...

The Jquery ajax get method is malfunctioning

I've been trying out this code but it doesn't seem to be working. Apologies for the basic question, but I'm curious to understand why it's not functioning as expected. $(document).ready(function(){ $("button").click(function(){ ...

Shifting static information both above and below a 100vh element

At the moment, I have a stationary image in the center of my screen that moves horizontally when scrolling with the mouse. Now, I want to include a screen above and below this element, each with a height of 100vh. However, when I attempt to do so, the fixe ...

Output JSON data to an HTML5 table

Here is a code snippet to retrieve data: function fetchInformation(){ $.get('http://mywebsite.net/getFile.php', function(data) { var result = JSON.parse(data); } The returned JSON data is as follows: Object {0: "11", 1: ...

JavaScript attaching a function to an element within an array

Can anyone explain why I am unable to assign the toUpperCase method to a specific value in an array like shown below? I'm a bit confused because I thought objects were mutable and manipulated by reference. Maybe my understanding is incorrect? var ary ...

Discovering whether a link has been clicked on in a Gmail email can be done by following these steps

I am currently creating an email for a marketing campaign. In this email, there will be a button for users to "save the date" of the upcoming event. I would like to implement a feature that can detect if the email was opened in Gmail after the button is cl ...

Using an ASP.NET control along with jQuery within a standalone .js file

I recently created a jQuery voting script that functions perfectly when the code is kept within the header of the page. However, I am interested in transferring it to a separate .js file and simply including this .js file at the top of the page. Strangely, ...

Unable to execute Javascript function within a click event handler

I am encountering an issue with a div that is loaded through ajax. Here is the structure of the div: <div id="container"> <a href="#" class="easyui-linkbutton submit_data">Click here to submit</a> </div> Within the same file c ...

The jQuery .Text() method efficiently replaces the contents of an element with fresh

I am experiencing an issue where the .text() function in jQuery replaces both the text and HTML within an element. I'm looking for a solution that allows me to only modify the actual text and leave the HTML intact. Any ideas on how I can achieve this? ...