How come my button is overflowing the container on Chrome?

I have adjusted a div to be 78% of the viewport height (78vh). Since there are 13 buttons, each button is set to be 6% of the viewport height (6vh) so that all 13 buttons should fit within the parent container size of 78vh. In Firefox, everything appears correctly, however in Google Chrome, the last button extends beyond the container. Can anyone explain why this might be happening? Please keep in mind that I am not well-versed in HTML, so a simple explanation would be greatly appreciated.

<body>
    <div style="height:85vh;overflow:auto;background-color:green;margin-top:10vh;">
        <div style="height:78vh;margin:2vh;background-color:white;">
            <div class="visible-sm-block visible-md-block visible-lg-block" style="background-color:yellow;height:78vh;margin-right:66%;">
                    <button style="height:6vh; width:12vh"> 0 </button>
                    <br><button style="height:6vh; width:12vh"> 0 </button>  
                    <br><button style="height:6vh; width:12vh"> 0 </button>
                    <br><button style="height:6vh; width:12vh"> 0 </button>
                    <br><button style="height:6vh; width:12vh"> 0 </button>
                    <br><button style="height:6vh; width:12vh"> 0 </button>
                    <br><button style="height:6vh; width:12vh"> 0 </button>
                    <br><button style="height:6vh; width:12vh"> 0 </button>
                    <br><button style="height:6vh; width:12vh"> 0 </button>
                    <br><button style="height:6vh; width:12vh"> 0 </button>
                    <br><button style="height:6vh; width:12vh"> 0 </button>
                    <br><button style="height:6vh; width:12vh"> 0 </button>
                    <br><button style="height:6vh; width:12vh"> 0 </button>
            </div>
        </div>
    </div>
    <script src="static/js/jquery.min.js"></script>
    <script src="static/bootstrap/js/bootstrap.min.js"></script>
</body>

https://i.sstatic.net/R8phj.png

Answer №1

Get rid of all <br> tags and apply the 'display:block;' style to buttons.

Answer №2

The issue here lies with the <br /> tags placed between the buttons. It seems that in Chrome, these <br /> tags are adjusting their height in increments as the window height changes. As a result, the overall height of the buttons may appear disproportionate.

To resolve this issue, one solution is to eliminate the <br /> tags and instead adjust the CSS display property of the buttons to block.

You can see the difference between the two approaches in this Fiddle: https://jsfiddle.net/0f5y1vj8/. The version with the <br /> tags is displayed on the right side. Experiment by changing the height of the result pane to observe how the spacing between the buttons reacts.

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 method for creating bootstrap columns within a single row that scroll horizontally instead of wrapping to the

I am looking to create rows with columns that total more than 12, arranged in a way that allows the columns to scroll horizontally. Here is an example of what I have attempted: <div class="container-fluid"> <div class="row" ...

After the submit button is disabled, the form fails to be submitted

Hello, I am having an issue with disabling my button after the form is submitted. The button gets disabled, but the PHP code does not execute. I have tried various scripts from the internet, but they all seem to have the same result: the button gets disab ...

Detecting coordinates (x, y) on a canvas

I'm currently working on a mini-game and encountering an issue with the player movement around the green square. My character seems to be unable to move past the x, y coordinates of the square, even though it can approach it closely. I would really ap ...

Transforming a fluid webpage into a fixed page

Currently, I am undertaking a project that involves converting a dynamic website like Adobe Spark into a static HTML+CSS page, which will eventually be transformed into a PDF. The interactivity of the website relies heavily on Javascript modifying CSS+HTML ...

The functionality of the jQuery .click method appears to be malfunctioning within the Bootstrap

It seems like my JQuery.click event is not functioning as expected when paired with the corresponding button. Any ideas on what might be causing this issue? Here's the HTML CODE snippet: <button id="jan7" type="button" class="btn btn-dark btn-sm"& ...

Is it possible for jQuery to operate on an HTML structure that is stored in memory

Exploring In-Memory HTML Structures with jQuery. Take a look at this snippet of HTML code: <div id="template" hidden="hidden"> <div class="col-md-3 margin-bottom20"> <p id="template-title" class="text-capitaliz ...

Alter the status of a checkbox programmatically

There are two checkboxes available: <input type="checkbox" id="id3"></input> <input type="checkbox" id="id4"></input> The desired functionality is that when clicking on id3, id4 should also be checked. Initially, this works as e ...

What is the method for incorporating multiple classes into an li element?

Here is the code I am working with: function createCardList(classname, cardName) { console.log(classname); var $li = $('<li class=' + classname + '>'); var $input = $('<input >', { type: 'radio&ap ...

Is Chrome capable of caching every single web page visited?

I am tasked with presenting an RPA script that clears cache. My idea is to create a web page as a demonstration. I want to cache this web page so that any changes I make in the HTML will not immediately show up. When I run the script, it should clear the ...

Activating Anchor's Pseudo Content on Hover of Another Element

I've encountered a straightforward issue - I have an anchor in a navigation menu that generates an arrowhead character as ::after pseudo content in CSS when hovering over it: https://i.sstatic.net/Yhd9A.jpg However, the arrowhead character disappear ...

Is there a way to adjust the width and create the illusion that the div is sliding in from off screen?

I successfully animated a side navigation menu to slide in from the left of the screen. The animation is working perfectly, however, I had to set the div's width to 0px in order for it to appear as though it's sliding in from off-screen. If I ch ...

Using PHP, identify a URL within text, verify if the URL refers to an image or a website, and then display the

Currently in the midst of a project that involves processing text containing various words and URLs, specifically images. The task at hand is to identify whether each URL within the text points to an image or a website. If it's an image, display it us ...

Display 3 images with the carousel feature on the middle image

Currently, I am utilizing the jquery.jcarousellite plugin and attempting to make the second image active. Below is the code snippet I have tried: <div id="jcl-demo"> <div class="custom-container auto moreItems "> <a href="#" c ...

Adjust the grid layout when minimizing

Is there a way to change the grid position when we minimize the screen? For example: <div class="row"> <div class="col-lg-6 -col-sm-12 col-xs-12"> <img src="http://placehold.it/350x150">//first image </div> <div class ...

Servlet-enhanced Turn-Based Gaming Experience

I am working on developing a turn-based game, similar to Checkers, using Servlets and JSP pages. I have set up a specific page with a newGame button that redirects players to the gamePage. This redirect sends one player to Black.jsp and the other to Red.js ...

Tips for preventing HTTP-request conflicts in JavaScript/AngularJS

Utilizing a combination of JavaScript and AngularJS, I encountered some challenges with HTTP-request race conditions. To simplify the issue for demonstration purposes: imagine having multiple scope.$watch listeners in place, where some may occasionally tr ...

Tailored alignment of checkboxes and labels

I've designed a custom checkbox where the actual checkbox is hidden and a label is styled to look like a checkbox. Everything works fine, however, when I add a label, it doesn't align properly. Here's the link to the fiddle: http://jsfiddle ...

Switch the default blue color of Ngx-Pagination to a different color option

I am currently using the ngx-pagination plugin in my Angular 16 project and I would like to change the default blue color to a different one, is there anyone who can assist me with this? https://i.sstatic.net/NNuy7.png This is the HTML code snippet: < ...

Adding a padding-left to a horizontal list within Flexbox enhances the design and structure

How can the left-padding added by Flexbox on a horizontal list be fixed even with justify-content: space-between? <div class="list-container"> <ul> <li>One</li> <li>Two</li> <li>Three</li> ...

Avoiding duplicate touch events with an if statement

I am currently working on a module for a responsive website that involves tapping the initial screen to reveal a panel from the right. The user can then tap a close button to hide the panel. However, there is an issue where if the user taps multiple times ...