Element within grid not stretching to full width

My experience with using grid is still quite fresh. Although I've completed a few projects, I'm struggling with some issues. One of them involves setting the grid element to 100%, but it seems to be getting clipped at 80%.

It appears like such a simple problem to solve, yet I've spent the last hour trying various solutions without success.

Important to note, I am incorporating a slider element from fomantic, which isn't visible in the code preview due to the small viewpoint.

body{
  margin:0;
}
.page-wrapper{
  width:100%;
  height:100%;
  
  display:grid; 
  grid-template-columns:10% 40% 20% 10% 5%;
  grid-template-rows:4vh auto 2vh auto 6vh;
  grid-template-areas:". . . . ."
                      ". page_heading page_heading page_heading ."
                      ". . . . ."
                      ". svg-container . user_controls ."
                      ". . . . .";
  
}

.page_heading-wrapper{
  grid-area:page_heading;
  width:100%;
}

.svg-container{
  grid-area:svg-container;
}

.user_controls{
  grid-area:user_controls;
}
<link href="https://cdnjs.cloudflare.com/ajax/libs/fomantic-ui/2.7.8/components/slider.min.css" rel="stylesheet"/>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/fomantic-ui/2.7.8/components/slider.min.js"></script>
<div class="page-wrapper">
  <div class="page_heading-wrapper"></div>
  <div class="svg-container">
      <svg class="user_svg_elem" height="210" width="400">
          <path d="M150 0 L75 200 L225 200 Z" data-path_to_mask />
          <path d="M150 0 L74 200 L225 200 Z" data-path_to_mask />
      </svg> 
  </div>
  <div class="user_controls ui slider"></div>
</div>

Answer №1

You haven't fully created a 100% Grid column. Your current setup of

grid-template-columns:10% 40% 20% 10% 5%;
only adds up to 85%. Adjust it to achieve 100% by changing
grid-template-columns:10% 40% 20% 10% 5%;
to
grid-template-columns: 20% 40% 20% 10% 10%;
. Now your grid has a total width of 100%. You can view an example here.

Additionally, include the box-sizing CSS property.

*,
*:after,
*:before{
  -webkit-box-sizing: border-box;
  -moz-box-sizing: border-box;
  box-sizing: border-box;
}

The box-sizing CSS property determines how the overall width and height of an element are calculated. More information can be found on MDN.

Answer №2

When calculating the total percentage of 10% + 40% + 20% + 10% + 5%, the result is 85%.

This could be where the issue lies.

Unlike tables that adjust percentages to always add up to 100%, grids do not work in the same way.

To address this, you can use the unit 'fr' instead of percentages:

grid-template-columns: 1fr 4fr 2fr 1fr 0.5fr;

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

The vertical navigation sub-menu is designed to overlap the div container for a

I'm having an issue with my sidepanel vertical navigation where sub-menus are not being displayed properly due to a div container. The width of the div container [side-panel-links] is causing the sub-menus and children of the sub-menus to be cut off. ...

The jQuery modal window is not appearing when trying to fade in

I want to set up a feedback form where all fields are filled out and the user has clicked the checkbox confirming they are not a robot. Once this is done, the Send button becomes active and a popup window will appear with a message saying "Thank you, we wi ...

Develop an occurrence that hides one <div> element and generates a fresh <div> element in its place

I am in the process of designing an experiment with a web-based notepad. Currently, I have a textarea element that transfers its content to a hidden div when the HTML page is printed. However, I am facing an issue with the overflow of the textarea element. ...

What is the method for switching the pre font family back to the default Bootstrap 5 style?

The default font for <pre> tags in Bootstrap 5 is typically a monospaced style, which suits most coding and programming needs. However, I'm looking to utilize a <pre> tag for formatting a poem where line breaks are crucial. In this case, I ...

Floating with Flex in Bootstrap 4: A seamless way to achieve

Is there a way to achieve this floating layout using Bootstrap 4 flex Grid? I've attempted to use the flex order function but encountered some issues. Have a look at my result: <div class="row align-items-start"> <div class="col-sm- ...

Increase the width of the Bootstrap column by one unit specifically for large screens

I'm currently trying to implement Bootstrap's documentation in order to create a layout where one column is wider than the other two. You can find my JSFiddle at the end of this post. If you'd like more information, you can check out the of ...

How can I locate the first word using XPath?

When dealing with the following HTML / XML code: <div class="contentBlock"> <h2> </h2> <h1></h1> <h1>DBS055 - single module packages</h1> </div> I am interested in extracting only the code D ...

How can CKEditor ensure that there is a paragraph tag within a div element?

Working on my current CMS, I have the need to include some custom HTML (which is functioning as expected): var element = CKEDITOR.dom.element.createFromHtml("<div class='sidebar'>Edit Sidebar Text</div>"); The issue arises when atte ...

Challenges arise when media queries fail to activate properly

Greetings! I am currently working on enhancing the responsiveness of my webpage using Media Queries. However, I seem to be facing a challenge with the second image not changing as expected when I reduce the browser size. In the HTML, 'top-background- ...

Is there a way to group together select values in a dropdown menu under a shared category?

If I have a dropdown menu that looks like for example: <select> <option value="1">1</option> <option value="3">3</option> <option value="2">2</option> <option value="4">4</option> </select&g ...

What could be causing my div to display a horizontal scrollbar in Firefox?

Here's a straightforward test scenario: <html> <body> <div style="border:2px solid black; overflow: auto;"> x </div> </body> </html> Upon rendering, a horizontal scrollbar appears! I was using F ...

A step-by-step guide on how to exclusively print items that have been selected using a checkbox in AngularJS

I have created two tables and added a checkbox for each one. Instead of default checkboxes, I have used images that change when clicked. Here is the code snippet: <button class="btn btn-lg btn-customPrint-md no-print" ng-click="checkBoxPrint2 = !check ...

launch active link in pop-up dialog

I'm currently working on an Instagram iframe that fetches 9 random images with href links for pictures and spans with the same background. My goal is to display these images in a popup gallery. I've tried using Bootstrap for the popup, but I&apos ...

Encountering a malfunction in executing the AngularJS controller file

In the project run with http-server and node.js, the angular controller is unable to connect with index.html. classifieds.js (function() { "use strict"; angular .module("ngClassifieds") .controller("ClassifiedsCtrl", ['$scope', ...

Issue with Sub-Menu closing unexpectedly upon hovering over Menu item

I created a webpage with navigation links that trigger separate menus to open upon hovering. Although I have successfully implemented this functionality, I encounter an issue when trying to click on a link within the sub-menu as it disappears. Below is a ...

Enhance the visual appeal of incoming data using Angular Material's dynamic styling feature

Is it possible to enhance the text with some CSS styling to make each item stand out like in this example: https://i.stack.imgur.com/kSyZE.png I prefer not to include a cross button or provide users with the option to add tags. The data is coming from a R ...

Troubleshooting issue with jQuery animate not correctly scrolling

I am experiencing an issue with my jQuery code that is supposed to scroll a smaller container element within a larger container element when a button is clicked. Despite testing with an alert and verifying that the code is working, the scrolling functional ...

redux form has encountered an error: the element type provided is not valid, a string is expected for built-in components

While working on my stepper code, I attempted to add a radio button. However, this addition resulted in the following error. I referenced this example before implementing it. Despite that, I am still encountering errors. Could you please advise me on how ...

Ways to refresh a div element without causing it to blink

I'm new to web development and I have an HTML webpage that retrieves data from a database and displays information based on the retrieved data. I would like to update the data every second without causing the webpage to blink. Can you please modify th ...

How can I retrieve the index of an element within a 2D array using JavaScript when the array is displayed on a webpage?

https://i.stack.imgur.com/GHx9p.png I am currently working on developing an Othello game board within an HTML page using Angular. The board itself is constructed from a 2D number array which I then display using the <table> tag on the webpage. Below ...