Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Border Height on CSS

Tags:

html

css

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; } 

It works fine but the problem is that the border's height takes the total TD's height.

Is there a way to set the height of the border?

like image 883
Satch3000 Avatar asked Apr 14 '11 13:04

Satch3000


People also ask

How do I add a border height in CSS?

You can set height to inherit for the height of the table or calc(inherit - 2px) for a 2px smaller border. Remember, inherit has no effect when the table height isn't set. Use height: 50% for half a border.

How do I lower left border height in CSS?

You can't. CSS borders will always span across the full height / width of the element. One workaround idea would be to use absolute positioning (which can accept percent values) to place the border-carrying element inside one of the two divs. For that, you would have to make the element position: relative .


1 Answers

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.

like image 139
ReBa Avatar answered Oct 04 '22 13:10

ReBa