What is the best way to align text within both the grid row and column while still maintaining the border?

When I apply justify-self and align-self rules, it successfully centers items vertically and horizontally. However, the issue arises when the borders wrap around the text instead of expanding all the way to the edges.

My goal is to have a 1px border around each cell so that they are not doubled up if they are adjacent to another cell.

div.around {
    width: 490px;
    margin: 0 auto;
}

div.padder {
    padding: 125px 24px 30px;
}

div.size-chart {
    display: grid;
    grid-template-columns: repeat(9, 1fr);
    grid-template-rows: repeat(9, 1fr);
    border: 1px solid #c4c4c4;
}

.size-chart div {
    border: 1px solid #c4c4c4;
}

.double-span-col {
    grid-column: auto / span 2;
}

.double-span-row {
    grid-row: auto / span 2;
}

.size-chart div span {
    font-weight: bold;
}

.theader {
    background: #e2e2e2;
}


  <div class="around">
    <div class="padder">
        <h2>Size Guide</h2>
        <div class="size-chart">
            <div class="double-span-col theader">
                <span>US</span>
            </div>
            <div class="theader">
                <span>UK</span>
            </div>
            <div class="theader">
                <span>FRANCE</span>
            </div>
            <div class="theader">
                <span>ITALY</span>
            </div>
            <div class="theader">
                <span>JAPAN</span>
            </div>
            <div class="theader">
                <span>BUST <i>(IN)</i></span>
            </div>
            <div class="theader">
                <span>WAIST <i>(IN)</i></span>
            </div>
            <div class="theader">
                <span>HIP <i>(IN)</i></span>
            </div>


            <div>XXS</div>
            <div>00</div>
            <div>2</div>
            <div>32</div>
            <div>34</div>
            <div>N/A</div>
            <div>30.5</div>
            <div>25.5</div>
            <div>34.5</div>

            <div class="double-span-row">XS</div>
            <div>0</div>
            <div>4</div>
            <div>34</div>
            <div>36</div>
            <div>5</div>
            <div>31.5</div>
            <div>25.5</div>
            <div>35.5</div>

            <div>2</div>
            <div>6</div>
            <div>36</div>
            <div>38</div>
            <div>7</div>
            <div>32.5</div>
            <div>26.5</div>
            <div>36.5</div>

            <div class="double-span-row">S</div>
            <div>4</div>
            <div>8</div>
            <div>38</div>
            <div>40</div>
            <div>9</div>
            <div>33.5</div>
            <div>27.5</div>
            <div>37.5</div>


            <div>6</div>
            <div>10</div>
            <div>40</div>
            <div>42</div>
            <div>11</div>
            <div>34.5</div>
            <div>28.5</div>
            <div>38.5</div>

            <div class="double-span-row">M</div>
            <div>8</div>
            <div>12</div>
            <div>42</div>
            <div>44</div>
            <div>13</div>
            <div>35.5</div>
            <div>29.5</div>
            <div>39.5</div>

            <div>10</div>
            <div>14</div>
            <div>44</div>
            <div>46</div>
            <div>15</div>
            <div>36.5</div>
            <div>30.5</div>
            <div>40.5</div>

            <div>L</div>
            <div>12</div>
            <div>16</div>
            <div>46</div>
            <div>48</div>
            <div>17</div>
            <div>37.5</div>
            <div>31.5</div>
            <div>41.5</div>

        </div>
    </div>
</div>

Answer №1

Have you considered using HTML <table> instead? Here's an example:

<table style="width:100%">
  <tr>
    <th></th>
    <th></th> 
    <th></th>
 </tr>
 <tr>
   <th></th>
   <th></th> 
   <th></th>
</tr>

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 website is displaying a "404 Error" for the font file at the specified path "GET

The fonts seem to be missing on my newly created website. What could be causing this issue? C:\Users\Berk\Desktop\twitter_video_downloader - Kopya │ ├── app.py │ ├── templates │ └── index.html │ ├── sta ...

Can the w3 validator be configured to disregard PHP tags?

I am facing issues with the online validator flagging errors for my php tags. To validate my HTML, I currently have to manually remove all the php inserts which is quite time-consuming. Is there a more efficient way to handle this problem? Below is an e ...

HTML Scripts: Enhancing Web Functionality

I have another question regarding executing a script (docs()) upon clicking on text. I attempted to use the following code: <p><span class="skill">Documentation can be found here.<script>docs()</script></span></p> Unfo ...

Is there a way for me to send a form containing pre-existing data from a different page?

Seeking advice: I realize that utilizing jQuery's ajax function may be the simplest approach, however I am facing an issue with the form field names. The var_dump below displays the typical values submitted by the form using test data. It appears that ...

Ensuring that nested objects in an absolutely positioned element do not wrap, clear, or stack

Looking for some assistance with my tooltip menu. The problem I'm facing is that my links keep wrapping to a new line, and I can't figure out how to prevent this. I've already attempted using display:inline and float:left on the links within ...

What is the reason for the malfunction of input :: - webkit-slider-thumb and input :: - moz-slider-thumb?

Designing a compact slider for enhancing user experience not limited to webkit browsers requires utilizing a scss template such as input { width: 100%; -webkit-appearance: none; -moz-appearance: none; appearance: none; height: 1vm ...

When should CSS compression and combining / JS minification be performed - at runtime or during build time?

I need to find a way to compress, version (for caching reasons), and possibly combine our JS and CSS files. I've come across two main approaches so far: 1) During the build process: Using an MSBuild task or similar. 2) Dynamically at runtime: Through ...

Ways to choose a designated element without relying on ids or classes

I am looking to create an on-click function for each button, so I require a method to select each one individually without relying on IDs <div class="col"> <div> <b>Name:</b> <span ...

Does the web browsing context within an iframe get reset when updating or specifying the src or srcDoc attributes?

Based on the official HTML5 specifications, it is stated that: When an iframe element is removed from a document, the user agent must discard the nested browsing context, if any This leads me to question whether changing the src or srcDoc attributes al ...

Running a <script> tag with an external src attribute in a dynamic manner through the use of eval

Currently, I am utilizing the Genius API to fetch lyrics for a particular song and then embed them within an HTML <div> tag. My interaction with this API is through PHP, employing an AJAX GET request. Upon a successful AJAX request, the following HT ...

Styling ReactJS Components with CSS Styling

I am a complete beginner to React and I seem to be facing an issue with rendering CSS properly. The react class, App, that I have should display a Card with a progress tracker on it. var App = React.createClass({ render: function () { var pushNotific ...

Using JavaScript, you can add an article and section to your webpage

Currently, I am utilizing AJAX to showcase posts. My objective is to extract each property from a JSON object that is returned and generate an <article> for the title followed by a subsequent <section> for the content. While I can successfully ...

PrimeFaces: Achieving Conditional Coloring Based on Status (Passed/Failed)

Attempting to dynamically change the color of a column based on its status value (Passed/Failed/InProgress) using jQuery. I tried copying and pasting the table into jsfiddle, where it worked. However, when implemented in the actual XHTML file, the jQuery ...

What is the best way to position images and URLs in div elements using CSS?

Currently, I am on a journey to become a Front End Developer through Udacity. As part of my learning process, I have a project that needs to be submitted. Unfortunately, I encountered some issues that I couldn't resolve on my own. Specifically, I&apos ...

positioning the cursor at the end of a content-editable div

When working with a contenteditable div, I encountered several issues specific to FireFox. To address these problems, I found that appending a br tag to the end of the div was necessary. <div id="testDiv" contentEditable="true"> Hey, click the butt ...

Why can't we use percentages to change the max-height property in JavaScript?

I am currently working on creating a responsive menu featuring a hamburger icon. My goal is to have the menu list slide in and out without using jQuery, but instead relying purely on JavaScript. HTML : <div id="animation"> </div> <button ...

It seems like there may be an issue with the React Table Pagination in reactjs

As a newcomer to React JS, I have been utilizing react-table to create a component that can filter, sort, and paginate sample data from a JSON file. If you are interested in the tutorial I am following, you can find it here: Currently, I am encountering ...

What is the best way to create a 6-column grid system without using bootstrap?

I am looking to create a row with 2 columns that should turn into 2 separate rows, each containing one column when viewed on smaller devices. I have researched CSS Grid but find it quite complex. Can someone simplify it for me? Thank you! ...

JQuery Mobile fails to apply consistent styling to user input check items within a list

I have successfully implemented the functionality to add user input items to a checklist. However, I am facing an issue where the newly added items are not adhering to Jquery Mobile's styling. Here is a screenshot showcasing the problem: Below is th ...

PHP MySQL query is causing multiple rows to be updated in the database

My goal is to update the quantity and price in two tables: Invoice and Order_Table. The updates should only apply to a specific OrderID. Here's my attempt: $UpdateQuant = "UPDATE Order_Table SET Quantity = '$NewQuant' WHERE OrderID = ' ...