简体   繁体   English

CSS Style TD 下边框

[英]CSS Style TD bottom border

I'm trying to style the bottom border of a TD.我正在尝试设计 TD 的底部边框。 The attached image shows this working as I'd like but the border is slightly too long, I'd like it to match the width of the blue cell above it.所附图像显示了我想要的工作,但边框有点太长,我希望它与它上面的蓝色单元格的宽度相匹配。

在此处输入图像描述

Here is my code:这是我的代码:

 table { border-collapse: collapse; width: 100%; } .tab { border-collapse: separate; background-color: #5B86EE; text-align: center; border-width: 1px; border-bottom: solid 3px #A0A0A0; border-top: solid 3px #E1E1E1; border-left: solid 3px #E1E1E1; border-right: solid 3px #E1E1E1; display: table-cell; border-top-left-radius: 5px; border-top-right-radius: 5px; } .active { background-color: #5B86EE; text-align: center; border-width: 1px; border-bottom-width: 2px; border-bottom: solid 3px #640000; border-top: solid 3px #E1E1E1; border-left: solid 3px #E1E1E1; border-right: solid 3px #E1E1E1; border-top-left-radius: 5px; border-top-right-radius: 5px; }
 <table border="0" width="100%%" align="center"> <tbody> <tr> <td class="tab">1</td> <td class="active">2</td> <td class="tab">3</td> </tr> </tbody> </table>

I have no control over the HTML being used, but I can change the CSS.我无法控制所使用的 HTML,但我可以更改 CSS。 Is there anyway to make the bottom border match the width of the cell excluding the left or right border width ?无论如何使底部边框与单元格的宽度匹配,不包括左边框或右边框宽度?

Also viewing this in Firefox and the border over hang is on the other end, so on the left not the right.同样在 Firefox 中查看此内容,并且边框悬垂在另一端,因此在左侧而不是右侧。

You could use a pseudo element instead of a bottom border:您可以使用伪元素而不是底部边框:

 table { border-collapse: collapse; width: 100%; } .active, .tab { border-collapse: separate; background-color: #5B86EE; text-align: center; border-width: 1px; border-bottom: solid 3px #A0A0A0; border-top: solid 3px #E1E1E1; border-left: solid 3px #E1E1E1; border-right: solid 3px #E1E1E1; border-top-left-radius: 5px; border-top-right-radius: 5px; position: relative; } .active:after { content: ''; display: block; position: absolute; top: 100%; left: 0; right: 0; border-bottom: solid 3px #640000; }
 <table border="0" width="100%%" align="center"> <tbody> <tr> <td class="tab">1</td> <td class="active">2</td> <td class="tab">3</td> </tr> </tbody> </table>

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

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