gpt4 book ai didi

html - border-radius 后面的背景颜色

转载 作者:行者123 更新时间:2023-12-02 00:56:24 26 4
gpt4 key购买 nike

我想知道,是否可以在 border-radius 后面设置背景颜色?

我想实现这样的效果: enter image description here

我使用这个 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 可以吗?还是应该添加更多对象?

最佳答案

你为什么不做这样的事情呢?它可以让您轻松获得所需的输出!

* {
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>

关于html - border-radius 后面的背景颜色,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34608018/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com