I was wondering, is it possible to set a background-color behind the border-radius?
I want to achieve this effect:
I use this HTML:
<div class="content-header" tabindex="-1">
<span class="html">TITLE</span>
</div>
<div class="content-txt-v2" tabindex="-1">
<p>
Content
</p>
</div>
and I use this CSS:
.content-header {
height: 18px;
line-height: 18px;
background-color: #4C741B;
margin-top: 20px;
float: left;
-moz-border-radius: 10px 10px 0px 0px;
-webkit-border-radius: 10px 10px 0px 0px;
-khtml-border-radius: 10px 10px 0px 0px;
border-radius: 10px 10px 0px 0px;
padding: 0px 14px;
font-weight: bold;
font-size: 14px;
color:#fff;
}
.content-txt-v2 {
clear: both;
width: 669px;
padding: 0 10px;
margin: 0px auto;
border: 2px solid #E9EAE3;
-moz-border-radius: 20px 10px 10px 10px;
-webkit-border-radius: 20px 10px 10px 10px;
-khtml-border-radius: 20px 10px 10px 10px;
border-radius: 20px 10px 10px 10px;
float:left;
background-color:red;
}
I added the above code in a JSFIDDLE
I tried to set the background-color of my content-txt-v2 div but with no succes. Can anyone guide me in the right direction? Is it possible with only two div's? or should I add more objects?
That is pretty hard to do, but you can fake it: https://jsfiddle.net/85c8ss94/1/
.content-header {
height: 30px;
line-height: 18px;
background-color: #4C741B;
margin-top: 20px;
float: left;
-moz-border-radius: 10px 10px 0px 0px;
-webkit-border-radius: 10px 10px 0px 0px;
-khtml-border-radius: 10px 10px 0px 0px;
border-radius: 10px 10px 0px 0px;
padding: 0px 14px;
font-weight: bold;
font-size: 14px;
color:#fff;
margin-bottom: -12px;
}
.content-txt-v2 {
clear: both;
width: 669px;
padding: 0 10px;
margin: 0px auto;
border: 2px solid #E9EAE3;
-moz-border-radius: 20px 10px 10px 10px;
-webkit-border-radius: 20px 10px 10px 10px;
-khtml-border-radius: 20px 10px 10px 10px;
border-radius: 20px 10px 10px 10px;
float:left;
background-color:red;
}
Why don't you do something like this? it gives you desired output without much headache!
* { box-sizing: border-box; } .content-header { height: 18px; line-height: 18px; background-color: #4C741B; margin-top: 20px; float: left; -moz-border-radius: 10px 10px 0px 0px; -webkit-border-radius: 10px 10px 0px 0px; -khtml-border-radius: 10px 10px 0px 0px; border-radius: 10px 10px 0px 0px; padding: 0px 14px; font-weight: bold; font-size: 14px; color: #fff; z-index: 10; /* z-index same as red bar*/ position: relative; } .content-header:after { position: absolute; top: 100%; left: 0; content: ''; background: #4C741B; width: 18px; height: 18px; display: block; z-index: 5; /* z-index less than red bar*/ } .content-txt-v2 { clear: both; width: 669px; padding: 0 10px; margin: 0px auto; border: 2px solid #E9EAE3; -moz-border-radius: 20px 10px 10px 10px; -webkit-border-radius: 20px 10px 10px 10px; -khtml-border-radius: 20px 10px 10px 10px; border-radius: 20px 10px 10px 10px; float: left; background-color: red; position: relative; /* for giving z-index */ z-index: 10; /* z-index equal to title block */ }
<div class="content-header" tabindex="-1"> <span class="html">TITLE</span> </div> <div class="content-txt-v2" tabindex="-1"> <p> Content </p> </div>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.