Border Height on CSS

前端 未结 12 1020
既然无缘
既然无缘 2020-12-12 21:55

I have a table TD and on the right of it I want to add a 1 pixel border, so I\'ve done this:

table td {
    border-right:1px solid #000;
}

12条回答
  •  挽巷
    挽巷 (楼主)
    2020-12-12 22:12

    I have another possibility. This is of course a "newer" technique, but for my projects works sufficient.

    It only works if you need one or two borders. I've never done it with 4 borders... and to be honest, I don't know the answer for that yet.

    .your-item {
      position: relative;
    }
    
    .your-item:after {
      content: '';
      height: 100%; //You can change this if you want smaller/bigger borders
      width: 1px;
    
      position: absolute;
      right: 0;
      top: 0; // If you want to set a smaller height and center it, change this value
    
      background-color: #000000; // The color of your border
    }
    

    I hope this helps you too, as for me, this is an easy workaround.

提交回复
热议问题