让我们先看看代码bolow
<p>
我希望div-main
选择div1
div2
。假设我有div1
而不是<p>
。在这种情况下,我如何选择div-main
{1}}
我试过了:
div1+div-main p{}
但它应该不起作用。那里有任何工作功能吗?
答案 0 :(得分:0)
使用.div-main > p {...}
选择p
元素中的.div-main
标记
但是如果您只想在.div1
元素(?)后面选择那些,请使用:
.div1+.div-main p { color: red; }
&#13;
<div class="div1">
<p>Hello There</p>
</div>
<div class="div-main">
<p>Hello There</p>
</div>
&#13;
答案 1 :(得分:0)
使用std::future
定位课程int main() {
using namespace std::literals;
{
auto fut1 = std::async(std::launch::async, [] { std::this_thread::sleep_for(5s); std::cout << "work done 1!\n"; });
// here fut1 in its destructor will force a join on a thread associated with above task.
}
std::cout << "Work done - implicit join on fut1 associated thread just ended\n\n";
std::cout << "Test 2 start" << std::endl;
{
std::async(std::launch::async, [] { std::this_thread::sleep_for(5s); std::cout << "work done 2!" << std::endl; });
// no future so it should not join - but - it does join somehow.
}
std::cout << "This shold show before work done 2!?" << std::endl;
}
使用.div1
查找下一个div1
类
使用~
定位儿童.div-main
>
p
答案 2 :(得分:0)
首先,类选择器必须以点&#34; .div-main&#34;开头。和&#34; .div1&#34;。代码:
.div1+.div-main p {
color:red;
}
.div2+.div-main p {
color:green;
}
&#13;
<div class="div1">
<p>next red</p>
</div>
<div class="div-main">
<p>Hello There</p>
</div>
<div class="div2">
<p>next green</p>
</div>
<div class="div-main">
<p>Hello There</p>
</div>
<div class="div-main">
<p>Green ? no!</p>
</div>
&#13;
答案 3 :(得分:0)
<强> HTML 强>
<body>
<div class="div1">
<p>Hello There</p>
</div>
<div class="div-main">
<p>Hello There</p>
</div>
</body>
<强> CSS 强>
<style>
.div-main p {
color:Blue;
}
</style>
https://www.w3schools.com/code/tryit.asp?filename=FEVSB2EMHKLD