[英]Combining div and span tag styles failing
There are two types of help text container I have. 我有两种类型的帮助文本容器。 One is in
<div>
other is in <span>
I wrote a css both in one style. 一个在
<div>
另一个在<span>
我用一种样式编写了一个CSS。 It's working good but those <div>
and <spans>
includes an arrow styled child <div>
and <span>
. 它运行良好,但是
<div>
和<spans>
包含一个箭头样式的子元素<div>
和<span>
。 I tried to combine that .arrow
styles but it failed in practice. 我尝试结合使用
.arrow
样式,但是在实践中失败了。 Is there a way combine those same styles? 有没有办法结合这些相同的样式?
HTML example for <div>
: <div>
HTML示例:
<div class="helptext" id="{{ id_for_label }}">
<div class="arrow"></div> Helptext is in here
</div>
HTML example for <span>
: <span>
HTML示例:
<span class="helptext" id="{{ id_for_label }}">
<span class="arrow"></span> Helptext is in here
</span>
CSS for both: 两者的CSS:
div[class="helptext"],span[class="helptext"] {
position: absolute;
display: none;
right: 15px;
margin-top: 3px;
padding: 10px;
border: 1px solid #3c578c;
background-color: #FCFCF0;
opacity: 0.9;
color: red;
border-radius: 5px;
box-shadow: 5px 5px 15px 1px dimgray;
text-align: justify;
font-size: 12px;
z-index:100000;
}
CSS .arrow example for <div>
: <div>
CSS .arrow示例:
div[class="helptext"] .arrow {display: block; position: absolute; border: 10px solid transparent;
border-bottom-color: #3c578c; top: -20px; right: 10px;}
CSS .arrow example for <span>
: <span>
CSS .arrow示例:
span[class="helptext"] .arrow {display: block; position: absolute; border: 10px solid transparent;
border-bottom-color: #3c578c; top: -20px; right: 10px;}
I can't combine last two css. 我不能结合最后两个CSS。
You are missing .arrow
in both selectors for your css 您在CSS的两个选择器中都缺少
.arrow
Use this 用这个
div[class="helptext"] .arrow,span[class="helptext"] .arrow{
position: absolute;
display: none;
right: 15px;
margin-top: 3px;
padding: 10px;
border: 1px solid #3c578c;
background-color: #FCFCF0;
opacity: 0.9;
color: red;
border-radius: 5px;
box-shadow: 5px 5px 15px 1px dimgray;
text-align: justify;
font-size: 12px;
z-index:100000;
}
I think you can .helptext .arrow
as selector, if you don't have another element with classname helptext
. 我认为如果没有其他具有classname
helptext
元素,则可以将.helptext .arrow
用作选择器。
You should use below code: 您应该使用以下代码:
.helptext {
position: absolute;
display: none;
right: 15px;
margin-top: 3px;
padding: 10px;
border: 1px solid #3c578c;
background-color: #FCFCF0;
opacity: 0.9;
color: red;
border-radius: 5px;
box-shadow: 5px 5px 15px 1px dimgray;
text-align: justify;
font-size: 12px;
z-index:100000;
}
.helptext .arrow {
display: block;
position: absolute;
border: 10px solid transparent;
border-bottom-color: #3c578c;
top: -20px;
right: 10px;
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.