Styling Table Rows with CSS for Curved Edges

I've been attempting to style a table with rounded corners and solid lines for the rows, but I'm encountering an issue:

tr {
     border-bottom: solid;
}

This approach is not yielding the desired results.

Here is the current state of my code: FIDDLE

Is there a way to achieve continuous solid row borders for my table?

Answer №1

To create solid lines in your table design, include the following CSS rule:

border-collapse: collapse;

This will remove the spacing between cells and prevent breaks in the borders of your table.

table {
  background: red;
  border: 1px solid #000;
  -moz-border-radius: 6px;
  -webkit-border-radius: 6px;
  border-radius: 6px;
  border-collapse: collapse;
}
td {
  border-bottom: 1px solid #000;
}
<table>
  <tr>
    <td>Row one, cell one</td>
    <td>Row one, cell two</td>
  </tr>
  <tr>
    <td>Row two, cell one</td>
    <td>Row two, cell two</td>
  </tr>
  <tr>
    <td>Row three, cell one</td>
    <td>Row four, cell two</td>
  </tr>
</table>

See the updated JS Fiddle demo here.

If you want to achieve curved borders in your table, you can combine:

overflow: hidden;

However, this might hide the border as well. Additionally, use:

box-shadow: inset 0 0 0 1px #000;

To mimic the border that is now hidden by the overflow property.

table {
  background: red;
  -moz-border-radius: 6px;
  -webkit-border-radius: 6px;
  border-radius: 6px;
  border-collapse: collapse;
  overflow: hidden;
  box-shadow: inset 0 0 0 1px #000;
}
td {
  border-bottom: 1px solid #000;
}
<table>
  <tr>
    <td>Row one, cell one</td>
    <td>Row one, cell two</td>
  </tr>
  <tr>
    <td>Row two, cell one</td>
    <td>Row two, cell two</td>
  </tr>
  <tr>
    <td>Row three, cell one</td>
    <td>Row four, cell two</td>
  </tr>
</table>

Check out the updated JS Fiddle demo here.

Answer №2

To adjust the spacing between table cells, apply border-spacing: 0; to the table element.

table {
  ...
  border-spacing: 0;
}

This should resolve the issue for you. Feel free to check out the updated example on this fiddle link: http://jsfiddle.net/crz9hhkt/9/

Answer №3

How about presenting it in this way?

   table {
      background: red;
      border: 1px solid #000;
      -moz-border-radius: 6px;
      -webkit-border-radius: 6px;
      border-radius: 6px;
      border: solid;
    }

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 Overflow-x in CSS and AngularJS

I could use some assistance with css. When adding another hexagon on the right side, it currently jumps down to create a new row rather than overflowing horizontally. How can I make it overflow with a horizontal scroll instead? Below is the css code: #fl ...

Display the page number when printing using CSS

I am struggling to display the page number at the bottom of my printable document. I followed a source on Stack Overflow, but unfortunately, it did not work for me. My current CSS attempt to achieve this is as follows: body { text-align: justify; } /* ...

Fixed position of the element within a parent stacking context

How can I ensure that the #icon appears below the #dropdown in the following example? https://i.stack.imgur.com/GoBcR.png The position: fixed of #container seems to be creating a new stacking context for its children. Changing the position value fixes th ...

Leverage variables in JavaScript to establish a unique style

function AdjustScale(){ scaleX = window.innerWidth / 1024; scaleY = window.innerHeight / 768; element = document.getElementById("IFM"); element.style.transform = "scale(" + scaleX + ", " + scaleY + ")"; } I'm facing an issue with thi ...

Updating the appearance of a non-declared HTML child component on-the-fly using Angular

Trying to dynamically adjust the style of an unspecified div is causing some trouble. Using Angular and PrimeNG, invisible divs are being generated that I cannot access through inline styles. The objective is to allow a user to input a width as a string (5 ...

How to Align Printed Output in Angular Components

I am a beginner in Angular and I am looking to display modal information. To print the data, I am using onclick=print(). The data shows up in the print preview, but it is not aligned correctly. Here is a screenshot of my page. I want to align the data prop ...

Is there a bug causing this div to load inconsistently in Chrome?

Currently, I am using Chrome Version 33.0.1750.154 m on Windows 7 Professional 64 bit operating system A few years ago, I developed a WordPress plugin that displays a cached and stylized Google Calendar. The plugin works fine but could use some improvemen ...

The dimension of HTML on an IOS web application

After successfully designing a web app that works well on desktop browsers and iPad Safari, I encountered an issue when trying to install it as a hybrid app using cordova 3.3.0. The problem arises with the height not displaying properly. Despite including ...

Achieving the full height of a parent element for a relatively positioned child

I am trying to create a layout with specific height requirements. Here is the code snippet: body, html { height: 90%; } #content{ width: 100%; height: 100%; } #sidebar { position: relative; width: 200px; float: left; height: 100%; backg ...

Applying a translucent layer of color to a jpeg image to create a subtle background effect

I am attempting to create a semi-transparent, solid background color on top of an <img> tag, while still showing the original image underneath at the same ratio and size. Below is a snippet of the code I am working with (let me know if you need more ...

Using a double border causes the div to appear bigger in size

I'm currently working with React and Tailwind CSS, and I have a specific design goal in mind: https://i.sstatic.net/rbVP1.png To achieve this, I added borders to both the + and - buttons, as well as a border on the parent div to encompass all elemen ...

Create personalized styles for each item within a stack with specific spacing using the @mui library

Is there a way to change both the background color and spacing area when hovering over each item in my list? https://i.stack.imgur.com/87TST.png <Stack spacing={4} divider={<Divider variant={`fullWidth`} orientation={`horizontal`} flexItem/>}> ...

The images on the carousel are not properly sized

Having an issue with Bootstrap 4 carousel where the images appear too big and zoomed in. Unsure of what's causing the problem. Here is the HTML code: <div class="carousel-inner"> <div class="carousel-item active col-xs-12 ...

Showing the Datepicker upon clicking the button

I am trying to implement a datepicker that shows up when a button is clicked. Unfortunately, my attempts have been unsuccessful so far. I am working with Materialize Css and have experimented with using an input type of text, but it's not quite what I ...

What is the best way to create a scroll effect for a single div?

Trying to figure out how to create a scrollable div block that moves independently while the other content remains static. Currently, when scrolling down, the div moves up and creates an unwanted space between the other elements. Any suggestions on how to ...

Design a dynamic rectangular division using CSS and Bootstrap 4 that adapts to different screen sizes

I am encountering difficulties attempting to replicate a full-width rectangle div on a website, particularly with issues related to responsiveness and mobility. Here is an example of the design I am trying to recreate. And here's what I've acco ...

Preventing the copying and pasting of HTML ruby tags

I am currently using ruby tags to include pinyin in my text. For instance: <p> <ruby>与<rt>yǔ</rt></ruby><ruby>摩<rt>mó</rt></ruby><ruby>拜<rt>bài</rt></ruby><ruby& ...

Making sure that the height of the <section> element is equal to the height of the viewport when the page

Is there a way to dynamically adjust the height of a <section> element to match the viewport every time the page is reloaded? Once the height is set, it should remain fixed even if the user resizes the window. For example, if the viewport's hei ...

Overlapping input labels in Angular MaterializeCSS

I am currently facing an issue while attempting to use Angular MaterializeCSS () for designing a form. The problem I'm encountering is that my labels and inputs are overlapping, and despite following the documentation instructions by wrapping my form ...

Move objects into the designated area to access all items located inside

How can I retrieve all the elements inside the droppable area? For example, if I drag ten elements to the droppable area and then remove three, how can I identify which elements are still inside the droppable area when a button is clicked? Has anyone enco ...