Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I add outer rounded corners to a div?

I'm looking to add "outer" rounded corners to the selected sidebar item to give the effect that this item is "pouring" into the content well.

In my example below, I'd like the .top to have a rounded bottom-right corner with a gray background, along with a similar top-right corner for the .bottom. What do you think?

I'm using Twitter Bootstrap and LESS, if that makes it easier.

jsFiddle: http://jsfiddle.net/3YXb2/

Turn this:

rendered

Into this:

enter image description here

Markup:

<div class="wrapper">
    <div class="sidebar">
        <div class="top">
            <p>Top</p>
        </div>
        <div class="middle">
            <p>Middle</p>
        </div>
        <div class="bottom">
            <p>Bottom</p>
        </div>
    </div>
    <div class="container">
        <p>Content</p>
    </div>
</div>

CSS:

body {
    margin:10px;
}
div {
    margin:0;
    margin-right:-4px;
    padding:0;
    display:inline-block;
    vertical-align:middle;
}
.wrapper {
    width:100%;
    display:block;
    border:1px solid;
}
.container {
    background-color:gray;
    width:70%;
    height:300px;
}
.sidebar {
    background-color:white;
    width:30%;
    height:300px;
}
.middle {
    background-color:gray;
}
.top,.middle,.bottom {
    width:100%;
    height:100px;
    display:block;
}
p {
    padding:40px 0 0;
    margin:0;
    text-align:center;
}
like image 367
Ryan Avatar asked Apr 24 '13 00:04

Ryan


1 Answers

Css3 offers the border-radius property. However, please note that this is not available for IE8 or any version lower. There are available hacks; but they are just that: hacks.

Usage looks like this:

    .sidebar {
        background-color:gray;
        width:30%;
        height:300px;
    }
    .middle {
        background-color:gray;
    }
    .top,.middle,.bottom {
        width:100%;
        height:100px;
        display:block;
    }
    .top{
        background: white;
        border-bottom-right-radius:10px;
    }
    .bottom{        
        background: white;
        border-top-right-radius: 10px;
    }

jsFiddle example

like image 183
What have you tried Avatar answered Oct 03 '22 09:10

What have you tried