Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

change height of right border [duplicate]

Tags:

html

css

My right border is 100% height:

border-right:1px solid #000000;

enter image description here

I'd like to make it shorter:

enter image description here

Is it achievable using CSS without changing the height of the div? I need div to be 100% height and only change that border.

like image 470
JavaScripter Avatar asked Nov 04 '25 17:11

JavaScripter


2 Answers

You can use a pseudo element to replace the right border. As you can choose the size/position of it you can simulate a border with it :

FIDDLE

HTML :

<div></div>

CSS :

div {
    height:200px;
    width:500px;
    background:gold;
    position:relative;
    border-top:10px solid grey;
    border-bottom:2px solid #000;
}
div:after {
    content:"";
    position:absolute;
    top:20%;
    right:0;
    width:2px;
    height:60%;
    background:#000;
}

Supports IE8 see caniuse

like image 125
web-tiki Avatar answered Nov 07 '25 10:11

web-tiki


This is also possible with pseudo elements. I don't know if this is what you're looking for:

fiddle

`

div:after{
  content:'';
  height:150px;
  width:200px;
  border-right:1px solid yellow;
  position: absolute;
  top:30px;

}
like image 32
lennon626 Avatar answered Nov 07 '25 08:11

lennon626



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!