Only apply inner borders to the table cells

I'm attempting to apply a table border only to the inner sections, excluding the borders on the first and last cells.

My attempt so far:

 .grid > div:last-of-type {
      border-right: none;
 }  

In the image provided, you can see that the last cell is now 5px wider than the rest. This is due to it trying to fill the empty space left after removing the padding... How can I eliminate the padding while keeping its height consistent with the others? Is there a way for all of them to stretch to fit? Please consider that adding a fixed height is not an option as the number of cells may change and their heights could vary.

I also attempted to add border-collapse:collapse;, which did stretch them (GREAT!), but the middle cell ended up slightly smaller than the others.

Here is a JsFiddle link: http://jsfiddle.net/ju76y/5/ (Images included in the fiddle)

.grid {
   width: 100%;
   overflow: hidden;
   background-color: green;
   display: table;
   table-layout: fixed;
   word-wrap: break-word;

   text-align: center;
   letter-spacing: 0px;
   word-spacing: 0px;
}

   .grid > div {
      display: table-cell;
      vertical-align: top;
      border-right: 5px solid red;
   }

   .grid > div:last-of-type {
      border-right: none;
   } 

Answer №1

If you'd like, consider including the following in the cell characteristic:

box-sizing:border-box;

Answer №2

To ensure proper alignment with other divs, the following CSS code can be used:

.grid > div:last-child > div {
   margin-top: -2px;
}

VIEW DEMO

The same adjustment should also be made for the first child:

.grid > div:first-child > div {
   margin-top: -2px;
}

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

There are two notable problems with Bootstrap 4 Tooltip. The first is that it appears when a button is clicked, and the second is that it shows up for disabled elements

I am currently experiencing an issue with my tooltip while using Bootstrap 4. In my index.html, I have the following script loaded: $('body').tooltip({ selector: '[data-toggle="tooltip"]', delay: { show: 550, hide: 0 } }); The proble ...

Ensure there is no space following the conclusion of the scrolling div

I am working on displaying a series of divs one after another. The scrolling works smoothly, but once the last div goes off screen, there is a gap before the first div comes back in view. I want the first div to immediately follow the last div without any ...

My div won't stay fixed in the layout no matter what I try

Being fairly new to css, divs, and everything in between, I decided to create a simple layout for my band without unnecessary links like bio or merch store. Instead, I wanted separate spaces for our video, music player, and a Facebook window. I successful ...

The issue of video tags not displaying previews on iPhone across all browsers is also accompanied by problems with controls not functioning correctly

As I delve into the world of HTML5 video tags, I encountered an issue where the video wouldn't show a preview frame initially. Instead, only the Resume button would appear. Furthermore, after playing the video with the Resume button, it wouldn't ...

"Enhancing User Interfaces with Dev Express Design and Ensuring HTML5

I have noticed that the Dev express controls I am utilizing are being displayed with embedded styling. After checking with the HTML5 validation tool at http://validator.w3.org/check, it appears that using embedded CSS is not recommended. Is there a method ...

Struggling with a non-functional jQuery navigation tab onclick feature

Within my Django template, I am working with a series of nav-tabs that are being populated by a context variable: <div class="content-object"> <ul class="nav nav-tabs nav-fill" id="object_tab" role="tablist"> {% for object in object_ ...

How can I convert a button to a link within an HTML table?

I have a question regarding buttons in my HTML table. Is it possible that upon clicking a button, the link button changes to "Un-Extend," and then switching back to the previous button when clicked again? How can I achieve this functionality? https://i.sst ...

Adjust the dimensions within the class in bootstrap

Objective: My goal is to adjust a CSS code to be 700 instead of 870, based on the second image. Challenge: Currently, the default value is set at 870 (as shown in picture 1), but I need to use CSS to change it to 700. I attempted to make this adjustm ...

Utilizing clean data for form processing

I am currently working on developing a BMI calculator for my program using Django Web Frameworks: Here is a snippet from my views.py file: def bmi(h,w): return(w*10000.00/(h*h) def bmi_view(request): form=Bmi_forms() if request.method==&apos ...

Creating a stunning visual effect in Angular: Nebular flip card with varying front and back heights

Is it possible to customize the heights of Nebular card front and back individually, rather than having them automatically adjust to match the content? For example, setting a specific height for each side regardless of the amount of text or content on th ...

Removing or hiding elements using jQuery

My HTML code includes a select tag, and when the value changes, I want to retrieve data from the database based on this new value. The data is then displayed in a new div. This new div contains a close sign that should hide the div when clicked by the user ...

Utilizing CSS to create a distinction between the content body and background sections

Can anyone help me figure out how to use CSS to separate the content area of my website from the background? I've attached a picture to demonstrate what I'm trying to achieve. Basically, I want the background on the sides to expand for users with ...

How to Customize Checkboxes with CSS

I'm attempting to customize the style of a checkbox on a form, and here is what my HTML currently looks like: <form id="feedback"> <input type="checkbox" id="option1" /> <label for="option1">Option</label> </form> H ...

Reposition buttons using JavaScript

I attempted to modify the button that appears at the top of an HTML page. <div class='play'> <input id="play" type="button" value="Play" onclick="mode('play');startSlideshow();" /> </div> <div class='pause ...

What is the best way to pass the record ID of the row when the user clicks on the edit button?

The substance ID saved to the session is always the last record ID in the table. I need to send the record ID of the row when the user presses the edit button. Currently, every time a button is selected, the record ID sent is the last one in the table. I ...

What R package is capable of analyzing HTML strings to identify words that are formatted as bold, italic, and other styles within the text?

I am facing a challenge with my dataset that contains a column of HTML content. Each entry in this column represents a paragraph of HTML code. Here is an example: html <- "<p id="PARA339" style="TEXT-ALIGN: left; MARGIN: 0pt; LINE ...

"Using Selenium in Python to navigate Google's search results and view the

Hello, I am new to using selenium and I have a specific task in mind. I would like to scrape the address search results from Google that are displayed on the sidebar column. I have successfully managed to use selenium to conduct searches on Google and land ...

Preventing div elements from being highlighted when double-clicked

I'm working with a div element that has a background image and I need help figuring out how to disable the highlighting effect when double-clicking on it. Is there a CSS property that can achieve this? ...

Is Bootstrap 4 only being utilized in a fraction of the project?

We have made the decision to streamline our site by utilizing only GRID and NAVBAR on the vast majority of pages. This eliminates the need to load unnecessary jQuery and bootstrap.min.js on every page. The only JavaScript required is for the NAVBAR functi ...

struggling to find the precise value in the array

my original result is displayed below: [status] => 1 [schedule_status] => 1 [cid] =>3 [cdate] => 16-10-18 01:10:52 [did] => 16 [jid] => 4 However, when I try to extract individual array values using the following code: $count = count($ ...