I want the left border of my div to show only to the half of the div. The same I would like to do to my right border but is should be set from the bottom of the div to the middle of the div. How can I achieve it?
相关问题
- Adding a timeout to a render function in ReactJS
-
Why does the box-shadow property not apply to a
- Add animation to jQuery function Interval
- jQuery hover to slide?
- Issue with star rating css
Good question. It's not possible using the border property.
The only thing that comes to mind, if you can set your div's
position
torelative
, is to use an absolutely positioned, 1 pixel widediv
. Not thoroughly tested but this should work:You'd do the same on the right hand side, replacing the
left
property byright
.Remember, the surrounding
div
needs to beposition: relative
for this to work. I'm not sure about whether the 50% height setting will work consistently throughout browsers - make sure you test it. You may have to resort to pixel measures if it doesn't.2018: For modern browsers:
You can use
border-image
with gradients something like...Demo: https://jsfiddle.net/hz8wp0L0/
Tool: Gradient Editor
Can I Use : border-image (IE11)
A sort-of similar but different approach to @Pekka's: use the
:after
pseudo-selector, like so:HTML Markup:
CSS:
...and a jsFiddle for good measure.
You can use:
The text is visible, but the border color will be only at half of the div size.