我想知道,是否可以在border-radius后面设置背景颜色?
我使用这个HTML:
<div class="content-header" tabindex="-1">
<span class="html">TITLE</span>
</div>
<div class="content-txt-v2" tabindex="-1">
<p>
Content
</p>
</div>
我使用这个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;
}
我在JSFIDDLE
中添加了上述代码我尝试设置content-txt-v2 div的背景颜色,但没有成功。谁能引导我朝着正确的方向前进?只有两个div可能吗?或者我应该添加更多对象?
答案 0 :(得分:2)
这很难做到,但你可以伪造它: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;
}
答案 1 :(得分:1)
为什么不做这样的事情?它为您提供所需的输出,而不会让您头疼!
tournament
&#13;
* {
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 */
}
&#13;