简体   繁体   English

1px 边框问题不显示

[英]1px border issue not displaying

I'm trying to highlight a specific product on the comparison table.我试图在比较表上突出显示特定产品。 The highlight color is Red but i'm having issues when using 1px, but when i use 2px it works fine but 2px is to big.突出显示颜色是红色,但我在使用 1px 时遇到问题,但是当我使用 2px 时它工作正常,但 2px 太大了。

Also noticed on this code snippet it does not display RED borders after i have added bootstrap, so attaching a screenshot.还注意到在此代码片段中,在添加引导程序后,它不会显示红色边框,因此附上屏幕截图。 在此处输入图片说明

My goal is to have Selected Product to be surrounded by RED 1px border.我的目标是让Selected Product被红色 1px 边框包围。 Also i would not mind any other tips of displaying these types of table.此外,我不介意显示这些类型的表格的任何其他提示。

I have also tried this but did not work: https://muffinman.io/fix-for-chrome-not-rendering-borders/我也试过这个但没有用: https : //muffinman.io/fix-for-chrome-not-rendering-borders/

Also looks like this is not Bootstrap issue, if i remove the BS and use border-collapse: collapse;看起来这不是 Bootstrap 问题,如果我删除 BS 并使用border-collapse: collapse; same problem同样的问题

 .table { margin: 20px; display: inline-block; text-align: center; } table, th, td { border: 1px solid #ddd; padding: 10px; } th:not(:first-child) { width: 200px; } table, th { font-weight: normal; } .border-sides { border-right: 1px solid red !important; border-left: 1px solid red !important; } .border-top { border-top: 1px solid red !important; } .border-bottom { border-bottom: 1px solid red !important; } .bg-selected { background-color: #b3c2ff; }
 <link href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css" rel="stylesheet"/> <div class="table"> <table> <thead> <tr> <th></th> <th> <div class="text-left"> <span>Title - Product 1 Test</span> </div> </th> <th class="border border-top"> <div class="text-left"> <span class="font-weight-bold">Selected Product:</span> <span>Title - Product 2</span> </div> </th> <th> <div class="text-left"> <span>Title - Product 2</span> </div> </th> </tr> </thead> <tbody> <tr> <td></td> <td> <button class="btn btn-primary">View</button> </td> <td class="border border-sides"> <button class="btn btn-primary">Buy now</button> </td> <td> <button class="btn btn-primary">View</button> </td> </tr> <tr class="text-left"> <td>Description 1</td> <td>Y</td> <td class="border bg-selected">N</td> <td>N</td> </tr> <tr class="text-left"> <td class="test">Description 2</td> <td>N</td> <td class="border bg-selected">N</td> <td>N</td> </tr> <tr> <td></td> <td> <button class="btn btn-primary">View</button> </td> <td class="border border-bottom"> <button class="btn btn-primary">Buy now</button> </td> <td> <button class="btn btn-primary">View</button> </td> </tr> </tbody> </table> </div>

Also double checked my BS is running first then my CSS or i'm missing something?还要仔细检查我的 BS 是否先运行,然后是我的 CSS 还是我遗漏了什么? 在此处输入图片说明

Is this the desired ouput?这是所需的输出吗?

UPDATED更新

 <link href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css" rel="stylesheet" /> <style> .table { margin: 20px; display: inline-block; text-align: center; } table, .table thead th, .table td { border: 1px solid #ddd; border-collapse: separate; border-spacing: 0px; padding: 10px; } table { padding: 0; border-width: 0 2px 0 0.5px; } th:not(:first-child) { width: 200px; } table, th { font-weight: normal; } .table thead th{ border-top-width: 1px; } .table tr:last-child td{ border-bottom-width: 1px; } .table thead th, .table td{ border-right: none; } .border-sides { border-right: 1px solid red !important; border-left: 1px solid red !important; } .border-sides + td, .table thead .border-sides + th{ border-left: none; } .border-top { border-top: 1px solid red !important; } .border-bottom { border-bottom: 1px solid red !important; } .bg-selected { background-color: #b3c2ff; } </style> <div class="table"> <table> <thead> <tr> <th></th> <th> <div class="text-left"> <span>Title - Product 1 Test</span> </div> </th> <th class="border border-top border-sides"> <div class="text-left"> <span class="font-weight-bold">Selected Product:</span> <span>Title - Product 2</span> </div> </th> <th> <div class="text-left"> <span>Title - Product 2</span> </div> </th> </tr> </thead> <tbody> <tr> <td></td> <td> <button class="btn btn-primary">View</button> </td> <td class="border border-sides"> <button class="btn btn-primary">Buy now</button> </td> <td> <button class="btn btn-primary">View</button> </td> </tr> <tr class="text-left"> <td>Description 1</td> <td>Y</td> <td class="border bg-selected border-sides">N</td> <td>N</td> </tr> <tr class="text-left"> <td class="test">Description 2</td> <td>N</td> <td class="border border-sides bg-selected">N</td> <td>N</td> </tr> <tr> <td></td> <td> <button class="btn btn-primary">View</button> </td> <td class="border border-bottom border-sides"> <button class="btn btn-primary">Buy now</button> </td> <td> <button class="btn btn-primary">View</button> </td> </tr> </tbody> </table> </div>

您可以为您的规则添加td ,例如td.border-top然后它使它比 BS 规则更具体并覆盖它

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM