Skip to main content
Participating Frequently
Oct 12, 2017 6:46 PM UTC
Question

is this type of border possible with CSS?

Hi,

I can handle doing a border on a div where it's just a rectangular border encompassing the div but is the type of combo border possible as in this picture?

https://s1.postimg.org/9pqkc8v5m7/css-border.jpg

Its like a rectangular border around a div and then combined with a horizontal rule that splits the rectangular div horizontally but the horizontal rule is not visible inside the div but only outside it.

I don't know if this type of border has a name or if it is possible via CSS.

    This topic is closed to new replies. Start a new post to keep the conversation going.

    5 replies

    pziecina
    Legend
    Oct 13, 2017 9:59 AM UTC

    You can create any type of border you wish, simply by using an image or even a combination of images, (different image on each side) using the css border-image property -

    https://developer.mozilla.org/en-US/docs/Web/CSS/border-image

    Translate
    B i r n o u
    Legend
    Oct 13, 2017 11:20 AM UTC

    border can also be used to draw any type of arrow, very usefull in portfolio gallery or webapp

    Translate
    Jon Fritz
    Community Expert
    Community Expert
    Oct 12, 2017 7:03 PM UTC

    It can be done, a lot of different ways with css.

    Personally I would use border and outline attributes, then do some fancy overlapping with absolute positioning and transforms...

    Here's an example (copy/paste into new document)...

    <!doctype html>

    <html>

    <head>

    <meta charset="utf-8">

    <title>self-contained-overlap-esque header dealy</title>

    <style>

        body {

            padding:0;

            margin:0;

        }

        .title {

            background-color:white;

            color:darkred;

            font-weight:bold;

            line-height:2em;

            text-align:center;

            border:6px solid #BDBDBD;

            outline:2px solid darkred;

            width:200px;

            position:absolute;

            left:50%;

            transform:translate(-50%, -50%);

        }

        .parent {

            position:relative;

            border-top:30px solid #BDBDBD;

            border-bottom:30px solid #BDBDBD;

            padding:1px;

            background-color:darkred;

        }

    </style>

    </head>

    <body>

    <div class="parent">

        <div class="title">OUR VALUES:</div>

    </div>

    </body>

    </html>

    Translate
    Nancy OShea
    Community Expert
    Community Expert
    Oct 12, 2017 8:18 PM UTC

    Yup.  I was thinking along the same lines (pun intended) .

    You could also use a background-image or SVG.

    Nancy

    Translate
    Nancy O'Shea— Product User & Community Expert