Reputation: 570
I have a div, padding set to 50px both left and right.
Is it possible to add the purple border?
I cannot add code to the HTML, this should be done with pure css if possible. I tried to trick this with border-image and adding gradients but I could only add like this:
div {
width: 150px;
height: 150px;
background-color: grey;
padding-left: 50px;
padding-right: 50px;
border-top: 5px solid black;
border-image: linear-gradient(to right, white 50px, purple 0%);
border-image-slice: 1;
}
<div>Content</div>
https://jsfiddle.net/u7zq0amc/1/
Upvotes: 0
Views: 38
Reputation: 272816
Use a pseudo element instead:
div {
width: 150px;
height: 150px;
background-color: grey;
padding-left: 50px;
padding-right: 50px;
position:relative;
margin-top:20px;
}
div:before {
content:"";
position:absolute;
height:5px;
top:-5px;
right:50px;
left:50px;
background:red;
}
<div>Content</div>
Upvotes: 1