What is the formula for determining the REAL innerWidth and innerHeight?

I am currently working on a responsive website using Bootstrap and I am looking to create an element that perfectly fits the screen size.

When I set the height/width to 100%, the browser includes the toolbar, other tabs, and the Windows taskbar in the calculation of the viewport size. How can I determine the dimensions excluding these elements? I have tried using innerWidth() and innerHeight(), but it is not giving me the desired results (as seen below).

The website I'm developing is quite simple, mainly consisting of a video carousel, and I want to avoid forcing users to go fullscreen or scroll unnecessarily.

Upon running the following code:

$(document).ready(function() {
    alert("Inner Height: " + $(document).innerHeight());
    alert("Inner Width: " + $(document).innerWidth());
}

(The same dimensions are returned when using $(window) as well.)

Here's a snapshot illustrating the issue:

Below is the code I have implemented:

<div id="videoModal">
    <div class="modal-dialog" role="listbox">
        <!--<div class="modal-header">-->
        <!--</div>-->
        <div class="modal-body">
            <div id="carousel" class="carousel slide" data-ride="carousel">
            <!-- Indicators -->


                <!-- Wrapper for slides -->
                <div class="carousel-inner">
                    <div class="item" ng-class="{active: !$index}" ng-repeat="video in videos">
                        <video id="{{video.videoId}}" controls>
                                <source src="{{video.webmUrl}}" type="video/webm"/>
                                <source src="{{video.mp4Url}}" type="video/mp4"/>
                                <!--<source src="{{video.ogvUrl}}" type="video/ogg"/>-->
                            </video>
                            <a class="left carousel-control" href="#carousel" role="button" data-slide="prev">
                                <span class="icon-prev" aria-hidden="true"></span>
                                <span class="sr-only">Previous</span>
                            </a>
                            <a class="right carousel-control" href="#carousel" role="button" data-slide="next">
                                <span class="icon-next" aria-hidden="true"></span>
                                <span class="sr-only">Next</span>
                            </a>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>

In addition, here is the CSS styling used:

#videoModal {
        display: none;
        position: fixed;
        top: 0;
        right: 0;
        bottom: 0;
        left: 0;
        z-index: 1050;
    }

If anyone has insights on how to solve this issue, I would greatly appreciate any help. It seems like there may be a key aspect that I am overlooking... Thank you in advance.

Answer №1

If I grasp the gist of your inquiry correctly, it appears that utilizing VH and VW units within your CSS document would be the most advantageous approach.

For instance, you could implement something along these lines:

.item {
    width: 100vw;
    height: 100vh;
    background-color: blue;
}

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

Displaying the focus icon on the active tab using Angular Material

I am currently utilizing Angular material to dynamically generate tabs in my HTML code. I'm trying to display a drop arrow icon on the active or selected tabs, but I am facing some challenges with the implementation. Below is the code snippet I have ...

Creating a function in JavaScript to return an Unsubscribe and Array from a Firebase Snapshot Listener in Svelte

In my SvelteKit project, I have integrated Firebase Firestore. I maintain a db.js file that contains various functions utilized in Svelte components. One such function is detailed below. export const Items = { async getMany() { let dbRef = db.c ...

Unable to retrieve email data from this PHP form

I've been working on implementing an email form on my website, but for some reason, I'm unable to receive emails from this form. HTML Code <form method="POST" action="processor.php" id="contactform" onsubmit="return(validateForm());"> ...

Utilizing an external API in Javascript for fetching data

Is it permissible for me to directly initiate an API request from JavaScript to an external API (in this scenario at ) using the XMLHttpRequest object? If not, what steps should I take to retrieve data from this source? Do I need to incorporate a PHP bac ...

Transform a PDF document into a Google Doc utilizing the capabilities of the Google Drive API version 3

I successfully uploaded a PDF file to Google Drive using a node server. However, I am struggling to find a way to convert it to a Google Doc format so that it can be downloaded later as a DOCX document. Here is the code snippet I've been working with ...

Sending POST data to a PHP file without the use of jQuery results in AJAX malfunction

I have been struggling to make an ajax alert layer work with a POST method for the past few days, and I cannot figure out why it is not functioning. I have successfully used the same code structure to send form data through ajax using POST on other admin p ...

Ways to integrate a CSS file into XSLT

I have a CSS file that looks like this: .table_class1DeffCell { border-top-width : 1; border-left-width : 1; border-right-width : 1; border-bottom-width : 1; } .table_class11DeffCell { border-bottom-color : 000000; border-top-color : 000000; border-right- ...

Looking to encode/decode a JSON response in order to transfer it to a different webpage

Currently, I have a website application where I am required to pass a JSON response (in string format) across the site. To achieve this, I have been using a hidden type value and passing it upon the submission of a link/button which subsequently triggers a ...

Tips for building a dynamic view using Angular

I am working on a project where I need to dynamically generate multiple horizontal lines using data from a JSON file, similar to the example in the image below. Here is my attempt: Component.html <div style="text-align: center"> <div ...

Retrieve information about the clicked item using the Backbone framework

I have a unique webpage that showcases an impressive collection of books. Each book listed on the page comes with essential information such as the title, price, and description. This data is imported from a JSON file. Excitingly, when users click on any ...

Develop a JavaScript function to generate a multiple selection form

Hey there! I have a question... Can I use JavaScript to create a multiple select form? Here's an example: <select name="item[]"> <option value="0">Option 1</option> <option value="1">Option 2</option> </select> &l ...

Tips for displaying span value within asp.net web pages

I have an HTML code snippet that looks like this: <tr> <td> <span>Full Name:&nbsp;</span> </td> <td> <span id="FullName_PDLabel"><b>--</b></span> </td> & ...

Server crashing as nodemon encounters mongoose issue

Currently, I am in the process of learning Node JS, Mongodb, and Express JS. My goal was to create a database using Mongodb Compass and store some data within it. However, every time I attempt to run my code, my nodemon server crashes after a few minutes o ...

Is it possible to capture key events within a frame even when the source differs?

I'm having trouble setting up a keydown listener on my page. The issue is that there's an iFrame within the page, and whenever I click inside it and press a key, the handler doesn't work. I've tried different methods from online resourc ...

Unable to import a text file using a semicolon as delimiter in d3

I'm just starting to learn JavaScript and the D3 library. I recently explored the "d3-fetch" module (available at https://github.com/d3/d3-fetch) and the d3.dsv command API (find it here: https://github.com/d3/d3-dsv). However, I am struggling to unde ...

Combining three.js geometry and selecting objects with an octree

I have been utilizing Three.js to showcase a variety of custom geometries in different positions and rotations. These geometries are static and do not change frequently, but users have the ability to manipulate them by adding, deleting, or altering the sha ...

Including a label for an array within an unnamed array in a JSON string

Is there a way to transform the following data: [{"name": "Donald"}, {"name": "George"}] Into this format instead: {MyArray: [{"name": "Donald"}, {"name": "George"}]} I am currently working on a database server that I built using node.js, express, an ...

Exploring the potential of Django to efficiently implement multiple listviews on a single webpage

Recently started working with Python and Django, but I may have bitten off more than I can chew. If anyone has the time to help educate me, I would greatly appreciate it. My main model deals with "work orders," each of which is linked to subsets of data. I ...

The ng-switch functionality does not seem to be functioning properly, even when the is

My ng-switch is displaying both buttons instead of just one when isActive is false. Can anyone help me figure out what I am doing wrong? <div ng-switch="user.IsActive"> <div ng-switch-when="false"> <button type="button" (click)="activ ...

Having trouble with Node.js child_process.exec when the command doesn't return any output?

Recently encountered an issue while using child_process.exec in nodejs. The problem occurs when the command returns nothing. Here is what I did: const {exec} = require('child_process'); const cmd = `ps -ef | grep -v grep | grep abc123.py`; exec ...