Artem Svirskyi
Artem Svirskyi

Reputation: 7849

intermittent border + border radius

Is it real to make such border through css?

intermittent border
I thought about

border: 3px solid white;
border-top: none;

and pseudo-element with gradient, but its not exactly the same.

Upvotes: 2

Views: 817

Answers (2)

itsmikem
itsmikem

Reputation: 2168

[Update: this can be done with a radial gradient, but Im no longer in front of my computer.]

I'm not sure that there's a border gradient (yet anyway), but I built something with nested s for you. Just an idea. It's just missing the solid white across the bottom. Hope it's helpful.

jsfiddle: http://jsfiddle.net/itsmikem/HfCT3/

css:

div {
     position:relative;
}
#outer {
    background: #cccc00;
    width:200px;
    padding:10px;
}
#mid {
    border-radius:10px;
background: #ffffff;
background: -webkit-linear-gradient(left,  #ffffff 0%,#cccc00 50%,#ffffff 100%);
background: linear-gradient(to right,  #ffffff 0%,#cccc00 50%,#ffffff 100%);
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#ffffff', endColorstr='#ffffff',GradientType=1 );
    padding:3px;
}
#inner {
    /*width:100%;
    height:100%;*/
    background:#cccc00;
    border-radius:10px;
    padding:10px;
}

html:

<div id="outer">
    <div id="mid">
        <div id="inner">stuff
        </div>
    </div>
</div>

Upvotes: 1

Danield
Danield

Reputation: 125651

You can do this by adding a pseudo-element with a gradient. transparent -> white -> transparent.

FIDDLE

CSS

div
{
    width: 600px;
    height: 200px;
    border: 5px solid black;
    border-radius: 20px;
    position: relative;
    margin: 50px;
}
div:before
{
    content: '';
    position: absolute;
    top:-5px;
    left:0;right:0;
    margin:auto;
    height: 5px;
    width: 80%;

    background: -moz-linear-gradient(left,  rgba(255,255,255,0) 0%, rgba(255,255,255,0) 1%, rgba(255,255,255,1) 17%, rgba(255,255,255,1) 85%, rgba(255,255,255,0) 100%); /* FF3.6+ */
background: -webkit-gradient(linear, left top, right top, color-stop(0%,rgba(255,255,255,0)), color-stop(1%,rgba(255,255,255,0)), color-stop(17%,rgba(255,255,255,1)), color-stop(85%,rgba(255,255,255,1)), color-stop(100%,rgba(255,255,255,0))); /* Chrome,Safari4+ */
background: -webkit-linear-gradient(left,  rgba(255,255,255,0) 0%,rgba(255,255,255,0) 1%,rgba(255,255,255,1) 17%,rgba(255,255,255,1) 85%,rgba(255,255,255,0) 100%); /* Chrome10+,Safari5.1+ */
background: -o-linear-gradient(left,  rgba(255,255,255,0) 0%,rgba(255,255,255,0) 1%,rgba(255,255,255,1) 17%,rgba(255,255,255,1) 85%,rgba(255,255,255,0) 100%); /* Opera 11.10+ */
background: -ms-linear-gradient(left,  rgba(255,255,255,0) 0%,rgba(255,255,255,0) 1%,rgba(255,255,255,1) 17%,rgba(255,255,255,1) 85%,rgba(255,255,255,0) 100%); /* IE10+ */
background: linear-gradient(to right,  rgba(255,255,255,0) 0%,rgba(255,255,255,0) 1%,rgba(255,255,255,1) 17%,rgba(255,255,255,1) 85%,rgba(255,255,255,0) 100%); /* W3C */
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#00ffffff', endColorstr='#00ffffff',GradientType=1 ); /* IE6-9 */

}

Upvotes: 2

Related Questions