Create the columnHeader to match the width of the CSS column

Here's what I attempted:

http://codepen.io/helloworld/pen/BcjCJ

I aim for each column to have the same width as the column header visually.

Currently, a slight difference in width exists between the column header and the actual column. Refer to the pen for details.

What is causing this "space" that makes the column header slightly wider?

UPDATE

I've discovered that text is responsible for creating scrollbars on the table.

Is there a way to include this scrollbar size in the first column header's width without resorting to JavaScript, perhaps by leveraging a smart CSS3/SASS function like calc() or similar?

I can't identify any erroneous padding/margin.

HTML

<div id="gridHeader">     
      <div class="columnHeader">Monday</div>
      <div class="columnHeader">Tuesday</div>        
  </div>
  <div id="gridContent">

    <!-- Monday Column-->
    <div style="background:lightblue;" class="column">
      <!-- ko: foreach-->    
      <div class="row">11111111111... </div>

      <div class="row">22222222222... </div>
    </div>

    <!-- Tuesday Column-->
    <div style="background:green;" class="column">
        <!-- ko: foreach-->
      <div class="row">fsadffsfsfsd ...   sad</div>
      <div class="row">fsadffsfsfsd ...    ad</div>
    </div>

  </div>

CSS

.columnHeader{
  border:1px solid red;
  background:yellow;
}

.columnHeader, .column{
  -webkit-box-flex: 1;

  /* This ensures uniform header width regardless of content */
  width:100%;  
  font-weight:bold;
  font-size:1.2em;

}

#gridHeader{  
  display: flex; /* current version */
/* Ensures uniform column width irrespective of content */  
  width:100%;  
  align-items: center;
  text-align: center;  
  position:fixed;
  top:0px;
  left:0px;
  height:50px;  
  background:gray;
}

#gridContent{  
  display: -webkit-box;
 /* Ensures uniform column width irrespective of content */
  width:100%; 
  position:fixed;
  top:50px;
  left:0px; 
  bottom:0px;
  overflow-y:auto;
  overflow-x:hidden;
}

*{ 
  box-sizing:border-box;
}
.row{
  height:200px;  

  overflow-y:auto;
  overflow-x:hidden;
  border:1px solid blue;
  background:orange;
}

Answer №1

In order to address this issue, it is important to eliminate the overflow-x and overflow-y properties from both your #gridContent and .row classes.

The presence of scrollbars is causing the alignment to appear off.

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

Retrieve a specific value in HTML <a> tag using JavaScript-Ajax in Django

I am currently working with Python 3 and Django. Within my HTML code, I have the following: {% for category in categories() %} <li class="c-menu__item fs-xsmall"> <a href="#" id="next-category"> {{ category}} & ...

Ways to adjust the brightness of any color when hovered over

Is it possible to create a universal effect where an element becomes darker or lighter when hovered over, regardless of the initial color? Here is an example: .change-color{ Background:green; width:100px; height:100px } .change-color:hover{ Background ...

What is preventing a nested flexbox from expanding to the entire width?

Here's an example of some HTML/CSS code: <div style="display: flex; background-color: yellow;"> <div style="display: flex;background-color: lightblue;">i am a NESTED flexbox</div> </div> This results in https://i.sstati ...

Can the Caption Adapt to the Image?

Code snippet: <script type="text/javascript> function displayNextImage() { x = (x === images.length - 1) ? 0 : x + 1; document.getElementById("img").src = images[x]; } function displayPreviousImage() { x = ...

Display unique JQuery special characters

I'm looking to modify this specific text Hello Mr ABC so that it appears as: Hello "Mr ABC". The text Mr ABC includes a unique non-printable character " ". P.S: Where can I find more information on this topic? ...

Having trouble accessing CSS images in JSF

Issue Details : I am currently facing a problem with setting menu background images in my JSF application using CSS properties. The file structure is as follows This is the CSS snippet Style.css #menu { height:35px; width:950px; backgrou ...

Switching the endpoint renders the middleware ineffective

I've encountered a puzzling issue with my NodeJs - Express server, which serves as the backend for my mobile application. The problem arises when I send post requests to certain endpoints like checkmail and checkusername using axios from the frontend ...

How to use image source and mouse hover effects in CSS3

Can we create a CSS3 class for the src, onmouseout, and onmousehover properties? <img src="http://www.example.com//images/pic.png" onmouseout="this.src = 'http://www.example.com/images/pic.png'" onmouseover="this.src = 'http://www.examp ...

Xpath is effective in Chrome Dev Tools, but does not seem to be functioning properly in RS

I am currently engaged in a project that involves extracting an HTML table containing specific text ("Current Prison History:") from various URLs that vary based on individual ID. I have attempted to utilize CSS selectors for this task, but encountered a c ...

Firefox throwing XML parsing error when SVG is encoded as data URI

Check out my codepen demo showcasing the issue: codepen.io/acusti/pen/mJmVRy Encountering an error when trying to load svg content in Firefox: XML Parsing Error: unclosed token Location: data:image/svg+xml;utf8,<svg%20viewBox='0%200%20120%2 ...

Unable to process form submission with AngularJS + Stormpath

I am facing an issue with form submission. Even though I believe that the login and password data are being sent correctly, nothing happens when I submit the form. I am attempting to submit the form without using ngSubmit because it is not feasible in my s ...

Incorporate a PHP file from an external website, as plain text or HTML

My dilemma involves a php file that resides on a particular website (for example: ). This script generates html content, primarily consisting of text formatted with tags like <h2>, <p>, and so on. The task at hand is to take this text and embe ...

What is causing the issue of my oversized images not showing up on GoDaddy?

I recently uploaded my website on GoDaddy and I am facing an issue where some of my small images (sizes: 872 × 546px) are displaying perfectly fine, but the large ones (banners with a size of 2700 × 900px) aren't showing up. Does anyone have ...

Decrease the font size of text using intervals in CSS

I'm facing a challenge where I need to decrease the font size by 10% every 2 seconds. <div class="shrink"> text </div> .shrink{ transition: 2s linear all; font-size : 20px; } Is there a way to achieve this using only CSS? ...

Tips for ensuring uniform button height across all cards

I am seeking advice on how to align all the buttons in different cards, despite varying text lengths, to be in the same position at the end of each card. Here is an example of what I am aiming for. Below is my HTML and CSS code: * { margin: 0px; pad ...

What could be causing my sticky positioning to not function properly when I scroll outside of the designated

My website is organized into sections, with each section corresponding to a hyperlink in the navigation menu. I've applied the CSS property position: sticky to my navbar, which works as expected within the section bounds. However, I want my red navbar ...

Check if the input value was chosen by pressing Enter instead of clicking on it

There is an input tag with the following attributes: <input type="text" name="cOperator" class="form-control scale-input operator" placeholder="Enter your ID" autocomplete="off" onkeyup="ajax_showOptions(this,'getEmp',event)" required> ...

What is the best way to horizontally align an element within a Material UI Grid item?

How do I align elements in the center of a Material UI Grid item? Check out this code snippet from my React project: <Grid container> <Grid item xs={4}> // Other content goes here </Grid> <Grid item xs={4}> // How can ...

Is it possible to integrate an html page within a wordpress website?

I'm a WordPress newbie but I have experience with HTML, CSS, JS, and PHP. Can anyone guide me on how to incorporate existing HTML pages into my WordPress site? I recently set up WordPress successfully on my domain hosted by GoDaddy (www.mydomain.com) ...

Ways to verify if the CSS background-color is set to white?

I am looking for a solution: $('*').click(function() { if($(this).css("background-color") == "#ffffff") { $(this).css("background-color") == "#000000" } });​​​​ that will execute on click of a specific cla ...