Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Non Uniform Dashed Border in Table Cells

I have applied CSS border-bottom:1px dashed #494949; on several consecutive cells of a single row of an HTML table, but the border is not uniform. The dashes at the end of each cell appear little longer. Dotted border is also not uniform. I am also using border-collapse:collapse;

Here is the screenshot:

enter image description here

Is there any way I can get uniform dashed border?

like image 486
Irfanullah Jan Avatar asked Mar 20 '12 12:03

Irfanullah Jan


People also ask

What 3 types of border styles can a table have?

border-bottom-style. border-left-style. border-right-style.

Is dotted table borders values are allowed?

The following values are allowed: dotted - Defines a dotted border. dashed - Defines a dashed border. solid - Defines a solid border.

How do you customize a dashed border in CSS?

Native CSS properties don't support the customization of border-style . Therefore, we use a trick with an SVG image inside background-image property. The SVG features give us the ability to change the distance between dashed lines, set custom pattern, add dash offset or even change a line cap.


1 Answers

The way I fixed this problem on my app was by adding an extra row with the same colspan as the row with the dashed border. The border will be uniform to the length of the span:

<table>
    <!--row with dashed border-->
      <tr>
          <td style = "border-bottom: 1px dashed green;" colspan="3"></td>
      </tr>
    <!--added row so dotted border looks uniform-->
      <tr>
          <td style="height: 5px;" colspan="3"></td>
      </tr>
    <!--existing rows with lots of columns-->
      <tr>
          <td></td>
          <td></td>
          <td></td>
      </tr>
</table>
like image 156
dizad87 Avatar answered Sep 21 '22 16:09

dizad87