I’m trying to design a website in which the main content container has rounded corners using the border-radius property. However, I am keeping a sidebar and a topside navbar fixed so they don’t move when a user scrolls up or down. It’s similar to what can be seen on Google Plus:
http://www.techzek.com/wp-content/uploads/gsmarena_00121.jpg.
My question is: How do I set a border-radius for a content-container with a z-index value less than the other elements so that the rounded corners are not overlapped and hidden by other elements when a user scrolls?
In the following example, I’d like the corner where the navbar and sidebar meet to be curved, but can’t figure out how
HTML:
<body>
<div class="navbar">
<ul>
<li><a href="#">About</a></li>
<li><a href="#">Services</a></li>
<li><a href="#">Sign In</a></li>
<li><a href="#">Contact</a></li>
</ul>
</div>
<div class="sidebar"></div>
<div class="contentcontainer"></div>
</body>
CSS:
html, body {
background-color: #eee;
height: 100%;
}
.navbar {
position:fixed;
width:100%;
height:50px;
display:inline;
z-index:2;
background: rgb(61,40,77);
}
.navbar ul{
float:right;
display:block;
padding-top:14px;
padding-right:10px;
}
.navbar li {
padding:15px;
display:inline;
}
.sidebar {
position:fixed;
height:100%;
margin-top:50px;
width:170px;
background: rgb(61,40,77);
color: #eee;
}
.contentcontainer {
position:absolute;
margin-left:200px;
margin-top:65px;
z-index:1;
width:82%;
max-width:980px;
background-color:#fbfbfb;
border-style:solid;
border-width:1px;
border-color:black;
border-radius:18px;
}
Is this what you want? Codepen
Here’s the trick. You make a circle with
border-radius. You place it in the intersection berween the nav and the sidebar. Setborder-color: transparentand get some shadow to set the color.