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

I'm having trouble modifying the backdrop to 'true' or removing it after setting it to 'static' in Bootstrap. Can anyone help me troubleshoot this issue?

I have been encountering an issue with changing the backdrop setting from 'static' to 'true' in Bootstrap modal. Here is the code I am using: $('#modal').modal({backdrop: 'static', keyboard: false, show: true}); ...

Troubleshooting Bootstrap select box design discrepancies

Currently revamping a website and encountered an unusual issue with select boxes. There seems to be an overlapping white space where the option values should be. Here's a visual reference: View Image of Select Box Issue Utilizing Bootstrap for the re ...

Inform jQuery that the draggable element is in the process of being dragged dynamically

Currently, this issue is a vital component of an ongoing task. Once we can resolve this issue, it will lead to the completion of this and another inquiry. The original objective can be found here: drag marker outside map to html element You can view the ...

Break down and extract elements using typedEvent in TypeScript

Within the external library, there is the following structure: export interface Event extends Log { args?: Result; } export interface TypedEvent<EventArgs extends Result> extends Event { args: EventArgs; } export type InstallationPreparedEven ...

Using jQuery to add HTML elements before the content of a list

I'm facing a challenge in dynamically adding new elements to my list. Through ajax, I retrieve HTML data from my database and aim to iterate through each new <li> element to gradually prepend them to the top of the list. This is the snippet of ...

Observing the occurrences of JavaScript events

Is there a way to track all JavaScript events in the browser? Such as, identifying the functions that have been executed and the parameters that have been passed in each JS file? I'm dealing with some obfuscated code and I'm looking to determine ...

Adding a programmatic option with additional data

I am encountering an issue with my select2 multi-select element that has an ajax data source. Upon loading, I need to automatically preselect options in my select2. Although I have successfully followed the instructions outlined in the documentation for po ...

Angular directive does not focus on the text box

I've been working on creating text boxes using a directive and I want only the first text box to be in focus. To achieve this, I am utilizing another directive for focus control. Below is my script: <script> angular.module('MyApp',[]) ...

What is the best way to update my lowdb database directly from the frontend in a next.js application?

As a hobby programmer with experience in React and Firebase, I have recently started using Next.js. I'm curious if I can utilize it as a JSON-based database for local applications on my Raspberry Pi. I have successfully set up LowDB to access data fro ...

Basic application - angular has not been declared

I'm currently diving into the realm of javascript and angularjs, following along with the tutorials on . After setting up a basic IntelliJ javascript project, I created two essential files: index.html <!DOCTYPE html> <html lang="en"> ...

Validating Laravel emails with JavaScript blur and utilizing AJAX and jQuery

Looking for a way to validate a form in Laravel without hitting the submit button? I've tried some code, but only the email format validation seems to be working. Any tips on what I should do next? I'm new to Ajax. PS: When I enter a valid email ...

"Learn the trick to replace the Ctrl + N shortcut in Firefox and initiate an AJAX request

Note: The answer provided by Juan Mendes has been selected as the best answer for my situation due to its usefulness. AxGryndr also offered valuable information, so I recommend reading both answers as they are beneficial in different scenarios. Thank you t ...

creating a personalized tooltip for every item within a dynamically generated @html.dropdownfor control in mvc3

Currently, I am developing a web project using MVC 3 and Razor in C#. In my code, I have implemented @Html.DropDownListFor to dynamically display items. Now, I would like to add tooltips for each item displayed by @Html.DropDownListFor. Here is the relev ...

transmit JSON formatted form data to an AngularJS platform

I have a webpage built on AngularJS with a login feature. I want to iframe this webpage onto my own page and automatically log in my users. Upon inspecting the AngularJS site, I noticed that the login procedure expects a json object. I have tried multipl ...

Preventing access to websites through a web application using JavaScript

I am in the process of creating a web application that enables users to create a list of websites they wish to block, preventing access from their browsers. My goal is to block websites on all browsers, but I have narrowed my focus to Chrome for now. I ha ...

Struggling to adjust the timeout to exceed 60 seconds

I have been attempting to set a timeout for 120 seconds or more, but no matter what I try, the requests are timing out after only 60 seconds. Things I have tried include: $.ajax({ url: URL, timeout: 120000, success: function(html){ co ...

Incorporate a font-awesome icon directly within the input field

My div element contains a span element, which in turn includes an i tag. However, the i element extends outside of both the span and div elements. I am attempting to place an eye icon inside an input field. Here is my current code - what adjustments shou ...

Struggling to make jQuery focus on duplicated input fields

I am working on a page that requires creating dynamic form fields based on user input. I am using Ajax to speed up form entry and prevent typos by connecting to my database. The issue arises when dealing with cloned form fields. They do not trigger the po ...

What steps are involved in incorporating dynamic pagination in PHP using this particular snippet of code?

I am looking for a way to display a list of numbers from 1 to 1000 in a single line with the ability to scroll. However, I need to exclude both "Prev" and "1" from this list. How can I achieve this? Below is the code snippet that I currently have: echo ...

Why is it that when I use require.js, all my modules appear to be loading at once when the page first

During the development of my single-page backbone app using requirejs, I encountered an issue when deploying to our beta server. The initial page load took around 20 seconds as it had to fetch all the necessary scripts. I initially believed that this dela ...