问题
Using CSS, how can I create a partial border as per image below
I can get the complete border with:
border: 1px solid #f5f5f5;
but only want to show maybe 30px at the top and botton of the vertical border with nothing imbetween?
can this be acheived?
Thanks as always,
回答1:
There is a CSS solution, but it's complicated and also requires HTML markup:
#box {
width: 200px;
height: 200px;
margin: 30px;
position: relative;
}
#box > div.corner {
display: block;
position: absolute;
width: 50px;
height: 50px;
}
.top {
top: 0px;
border-top-style: solid;
}
.bottom {
bottom: 0px;
border-bottom-style: solid;
}
.left {
left: 0px;
border-left-style: solid;
}
.right {
right: 0px;
border-right-style: solid;
}
<div id="box">
<div class="corner top left"></div>
<div class="corner top right"></div>
<div class="content">content</div>
<div class="corner bottom left"></div>
<div class="corner bottom right"></div>
</div>
DEMO
来源:https://stackoverflow.com/questions/12445347/css-partial-border-to-create-place-holder