Is the overlap of viewport unit VW less than 100 vw per viewport?

So if I am correct, 1vw represents 1/100th of the width of a viewport, meaning there are 100vw across any given viewport. But here's an interesting scenario - when I have two divs each with a width of 25vw, one positioned 25vw from the right edge and the other 25vw from the left edge, they end up overlapping significantly. What's intriguing is that this behavior is consistent across different browsers. Why do you think this happens?

#sign_up_button{
    position: fixed;
    padding: none;
    top: 68vh;
    right: 25vw;
    width: 25vw;
    border: solid;
}
#login_button{
    position: fixed;
    top: 68vh;
    left: 25vw;
    width: 25vw;
    border: solid;
}
<div id="sign_up_button">Test</div>
<div id="login_button">Test</div>

Answer №1

To ensure the border is included in the width of your div, you must adjust your width calculation to account for the border size. Your current div width is calculated as 25vw + <border size>, so make sure to utilize the box-sizing property to incorporate the border into the width definition.

div {
  -webkit-box-sizing: border-box;  
  -moz-box-sizing: border-box;  
  box-sizing: border-box;  
}

For more detailed information, visit: https://developer.mozilla.org/en-US/docs/Web/CSS/box-sizing

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

Applying position: absolute in HTML/CSS to lock parent and child elements in

Transform the boxes into concentric circles (circles within each other that share the same center). The outer circle should be black with a size of 300px and the inner circle should be white with a size of 200px. html: <div id="p10"> <div id ...

Fixed width select2 input group

Why does the input group select 2 element disrespect the parent element width by extending beyond what is necessary? Selecting a normal option appears to be fine. However, when I choose a longer option, it ends up looking like this. Is there a way to se ...

Showcasing only one item at a time in AngularJS 1.x with ng-repeat; by clicking on "next", the subsequent item will be displayed,

Currently, I am working on a quiz web application that requires displaying a total of 100 questions across 3 different tabs - Math, GK, and English. The questions are filtered using an Angular filter. However, I'm facing an issue where each tab is sho ...

Impossible to create margins on both the left and right side

Check out this cool pen: http://codepen.io/helloworld/pen/BcjCJ?editors=110 I'm facing an issue where I'm unable to create both left and right margins around my datagrid. Only the left margin seems to be possible. Any suggestions on how I can f ...

"Unusual" symbols encountered during PDF file saving

I have a PDF file titled "SA Pias - Margaça Branco.pdf" that I need to access. Currently, I am using this link: href="SA Pias - Marga%E7a Branco.pdf" Although the file opens fine in the browser, when users try to save it, they see strange characters ins ...

Instruments for crafting an application compatible with a wide range of web browsers

Currently tackling various browser challenges. I find myself wondering whether it's achievable to create an application that is compatible with all browsers, or at least the majority. Should it be a web application? Any recommendations on frameworks a ...

Is there a way to incorporate two Bootstrap navbars on a single page that are of varying heights?

Utilizing Bootstrap 3.0 with dual navbars on a single page that adjust in height using the same variable for both .navbar blocks. Despite attempting to incorporate an additional class to alter the height of the initial navbar, it remains unaffected. Check ...

Adjusting Width with Javascript

My goal is to specify the width of a RadNumericTextBox that appears as an input element on the page using JavaScript. I have managed to set the width, however, the telerik controls come with built-in JavaScript functions that reset the input element' ...

Why is IE6 adding an additional margin of 50px? My code seems to be causing this issue

Currently I am working on creating a custom IE6 CSS. However, I am facing an issue where an extra 50px is being added to the header div. Even though I have set the header size to 109px, it is displaying at 159px. When I add any element below the header div ...

Issues encountered with the delete function using distinct row identification format

I am encountering an issue with variable value in input field. To provide some context, I have client information stored in a MySQL database. Using PHP, I retrieve this data and display it in a table. Currently, I am working on implementing a delete optio ...

"Enhance your Vue.js application with the powerful capabilities of vue3-easy

I am currently working on a Vue.js project utilizing the "vue3-easy-data-table" library and following the style recommendations outlined on this particular webpage: Despite attempting to apply the following CSS properties: --easy-table-body-even-row-font ...

displaying li tag depending on the index value within angularjs

I have an HTML structure similar to the following: <div class="main"> <ul> <li ng-repeat='save in saves'> <h3>{{save.name}}</h3> <div > <ul> ...

Items in the Vue.Draggable display can be arranged on both the left and right

Recently delving into Vue.js, I am utilizing Vuedraggable for item dragging in my project. Currently, the items in the draggable div are shown as Text 1 Text 2 Text 3 Text 4 Is there a way to rearrange them to display like this? Text 1 Text 2 Text 3 T ...

The sample Ajax XML code provided by W3Schools is ineffective

While studying xml parsing in ajax on w3schools.com, I came across an example that functioned perfectly online. However, when I saved it to my desktop as abc.html and note.xml, the XML values weren't displaying. Even though the HTML elements were vis ...

Adjust the height of one div to make it scrollable when another div overlaps and reaches the end

When I look at the image, I can see that the cart items are scrollable. However, when I open the promotion accordion, it overlaps with the center contents and hides the end items behind the accordion contents. https://i.sstatic.net/xxAxb.png The position ...

The navigation bar is failing to display all of the titles

Having trouble with my HTML page. I can only see the first word of the title in the drop-down list. The navigation bar refuses to center despite trying various styles. Below is my CSS code: background-color: #78706e; height: 100%; font-family: Arial; c ...

Update Table Row Background Color in Separate Table by Clicking Button Using JQuery

Two tables are involved in this scenario - one that receives dynamically added rows, and another that stores the data to be included. The illustration above displays these tables. Upon clicking the Edit button, the information from the selected row in Tab ...

"Trouble arose when I tried to incorporate additional functions into my JavaScript code; my prompt feature is not

As a beginner in HTML and JS coding, I am working on creating a page that prompts user input for a name and then executes animations using radio buttons. However, after adding functions for radio button changes, my prompt is no longer functioning properly. ...

Tips for displaying <p> element upon hovering over a specific area of an SVG image

I created a map and converted it to SVG. I want to display the name of each neighborhood when a user hovers the mouse over it. I'm not sure how to achieve this or how to isolate the specific area of a neighborhood to make changes. Here's a scre ...

The webpage is inaccessible only on mobile Safari, with an error message indicating a lack of internet

Initially, I do not possess an iPad, however, some clients have reported an unusual issue with one of my websites on the iPad. They are unable to access any page on the website, instead encountering a blank page with the error message: "Safari cannot open ...