Ensure that the entire webpage is optimized to display within the viewport

My goal is to make the entire website fit perfectly into the viewport without requiring any scrolling. The main pages I am focusing on are index, music, and contact, as the other two pages lead to external sources (you can find the link at the bottom of this post).

I have attempted various methods, but none of them seem to work as expected. It's possible that I might be implementing them incorrectly.

  • Initially, I tried setting the body's max-height to 100vh, but it did not produce the desired result. Then, I wrapped the whole page in a div with the same max-height property, still with no success.

  • Subsequently, another approach involved styling the html and body elements as follows:

       html body {
       margin: 0;
       min-height: 100%;
    }
    
  • A similar attempt was made using 'vh' instead of percentage in the CSS:

        html body {
       min-height: 100vh;
       position: relative; //I added this for potential sticky footer implementation
       margin: 0;
    }
    
  • Furthermore, I came across a JavaScript solution from someone else, which aimed to apply CSS to adjust the cover div (or in my case, the body tag or the container div of all content) to match 100 viewport height and width.

    var vHeight = $(window).height(),
    vWidth = $(window).width(),
    cover = $('.cover');
    
    cover.css({"height":vHeight,"width":vWidth});
    

Unfortunately, none of the above approaches yielded the desired outcome. Can anyone provide any tips or hints on how to achieve this successfully?

Link to the site:

Edit:

HTML Structure:

<div class="container-fluid">
<div class="row">
    <section id="intropage">
        <section id="container-banner">
            <div class="section first">
                <div class="cont_title">
                    <h1><a href="music.html">Music</a></h1>
                </div>
            </div>
            <div class="section">
                <div class="cont_title">
                    <h1><a href="tour.html">Tour</a></h1>
                </div>
            </div>
            <div class="section">
                <div class="cont_title">
                    <h1 class="font-weight-bold">Members<br>Only</h1>
                    <h3>Free Song<br>upon Sign-Up</h3>
                    <a href="http://www.holyrollerbaby.com/members/">
                        <button class="btn hoverable">Enter</button>
                    </a>
                </div>
            </div>
            <div class="section">
                <div class="cont_title">
                    <h1><a href="https://holyrollerbabyofficialstore.bigcartel.com/">Store</a></h1>
                </div>
            </div>
            <div class="section">
                <div class="cont_title">
                    <h1><a href="contact.html">Contact</a></h1>
                </div>
            </div>
        </section>



<div class="video-container">
    <video autoplay loop muted>
        <source src="http://www.icutpeople.com/wp-content/themes/icutpeople/assets/video/waynesworld.mp4"
                type="video/mp4">
        Your browser does not support the video tag.
    </video>
    <div class="overlay-desc text-center">
        <h1 class="white-text">"Spread Your Love Around" <br>Music Video Out Now!</h1>
    </div>
    <div class="overlay-icons">
        <a href="https://www.facebook.com/holyrollerbaby/"><i class="fa fa-facebook"></i></a>
        <a href="https://www.instagram.com/holyrollerbaby/"><i class="fa fa-instagram"></i></a>
        <a href="https://www.youtube.com/channel/UC9xenomg5a4OcN0wz4X2msg?view_as=subscriber"><i class="fa fa-youtube"></i></a>
    </div>
</div>

CSS Styling:

// Various media queries...
...
// Specific styles for video container and overlay elements
...

// Styles for homepage banner sections
...

.logo{
    ...
}

// Additional styles for different elements
...

Answer №1

When you adjusted your container-banner to 75vh, the video was unable to fit properly due to the banner consuming 75% of the screen space.

Answer №2

One effective approach is to enclose your website within a wrapper container set to absolute positioning spanning the full width and height of the site.

Here's an illustration:

.site-wrapper{
    position: absolute;
    width: 100%;
    min-height: 100vh;
    height: 100vh;
    top: 0;
}

Answer №3

.content {
    width: 100vw;
    height: 100vh;
    /*To truly enforce the rule*/
    overflow: hidden;
}

.All following children{
     position: relative;
     width: 100%;
     height: 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

Sort through a list of objects by certain properties

I'm currently dealing with two arrays: one contains displayed columns and the other contains objects retrieved from a database, with more attributes than the displayed columns. displayedColumns = ['CompanyName','Ticker', 'Id& ...

Tips on avoiding a page reload following a form submission using JQuery

Currently developing a website for my app development project, I've encountered an unusual issue. Utilizing some JQuery to transfer form data to a php page called 'process.php' and then add it to my database. The strange part is that the pa ...

Can Googlebot detect changes made to an HTML <title> tag using JavaScript?

Within my website, I have a search engine that operates using ajax technology. My goal is to assign a unique <title> for every search request made. This involves modifying the title each time I receive a response from the ajax feature. I am wonderin ...

Is there an HTML editing tool that has the ability to collapse code blocks by tags and rearrange them?

I'm in search of a text editor or IDE that includes syntax highlighting and allows me to collapse HTML code blocks by tag. I currently use Eclipse, but its "folding" feature only works on top level tags like TABLE, not child tags like TD and TR. Are t ...

Using Rails and HAML to incorporate looping HTML5 video tags

I have a question regarding how I'm using Rails video_tag to display a video: = video_tag("SMR_video.mp4", :controls => false, :autobuffer => true, :autoplay => true, :loop => true, :id => "hero-video") After implementing the above co ...

The Unicode range [uXXXX] in Regex is not recognized during the AJAX request

I am currently facing an issue with removing control characters (e.g. \u0005) from the ajax response string. I have implemented a regular expression for this purpose: msg = msg.replace(/[\x00-\x1F\x7F-\x9F]/g, ''); Inter ...

Utilizing Sails.js: Invoking a YouTube service through a controller

I am facing an issue while trying to integrate Youtube Data API with Node.js in Sails.js. The problem lies with the "fs.readFile" function. Upon launching the service, it returns "undefined". Below is the code snippet for YoutubeService : module.exports ...

Increasing the size of the .ui-btn-left component

Seeking advice on a Javascript query that I can't seem to resolve online. As a beginner in Javascript, I'm struggling with what seems like a simple issue. My dilemma lies in enlarging the close button on a jQuery page. .ui-dialog .ui-header .ui- ...

Is the "sticky footer" in CSS causing issues with the percentage height of nested divs?

My "main-section" div is designed to inherit its height from the parent div, known as the "wrapper." The wrapper div, in turn, takes its height from the body of the document. Both the HTML and body tags are set with a height of 100%. To implement the ...

What is the best way to eliminate the header and side navigation in a master page design?

I've set up a master page called wrap.master which is connected to multiple content pages. I'm looking to create a new content page and link it to the master page. However, I want this new content page to be independent from the header and side n ...

Stop the WebGL Three.js container from capturing scroll events

I am working on a full-screen three.js application which serves as the background and I am trying to add overlaid text that can be scrolled. However, my issue arises from the fact that the three.js WebGL container intercepts all scroll events and prevents ...

JavaScript API Response - conditional statement for handling a 'null' response

Does anyone have any suggestions for the following scenario: I have a response in .json format containing personal data of a person, who may or may not be assigned to a project. Here is an example response where the person is not assigned to a project: & ...

Ways to reduce the width of a flex box

I am facing an issue with my main container where I have two items placed on the same line. Item 1 is an image linked to a URL and it should be positioned at the far left of the container. On the other hand, item 2 contains a font awesome icon that needs t ...

Monitoring the progress of file uploads within itemView

In the process of developing an application using Marionette/Backbone, I have successfully implemented file uploads over an AJAX call. Now, I am looking for a way to provide users with feedback on when they can select the uploaded file and proceed with mod ...

What is the best way to specify the border color of a fieldset?

Is there a way to set the border color of a fieldset while removing the default border color? I have tried using a class but it doesn't seem to work as expected. How can I achieve setting the border color for the fieldset? <fieldset class="field_s ...

Store text in a table format in your local storage

I need help figuring out how to save product and price information to local storage when an "add to cart" button is pressed. Can someone provide guidance on how to do this? Here is the code I currently have: body> <!-- Header--> ...

Troubleshooting Dynamic Input Issue - Incorrect Appending Behaviour - Image Attached

I am working on a project that involves adding input fields dynamically using JavaScript. However, I've encountered an issue where the styling of the first input field is not applied correctly when it is clicked for the first time. You can see the dif ...

Add an HTML template tag in Vuetify using scripting

This is my current template tag: <template> <h1>Explore in VR</h1> </template> Within my script tag, I've included the following code: var viewer = new AFrame.WebVRViewer(); viewer.setSize(window.innerWidth, window.innerHeig ...

Analyzing various field data collectively

Is there a way to use jQuery to compare multiple input field values and trigger an alert message saying 'There are similar values' if any match is found? <input value="111"> //similar <input value="222"> <input value="111"> //s ...

Background loading of child application in single-spa

I'm currently working on setting up a Single-Spa micro frontend with Dynamic Module Loading in React. The user journey I have in mind is as follows: Root Application -> Authentication Application -> User Enters Details -> API Call -> Redir ...