【发布时间】:2017-03-15 19:42:52
【问题描述】:
我一直试图找到一种方法,通过 div> 标签> 和 p> 中的文本内容过滤掉我的可扩展 div。我将把我的例子放在下面。我已经从以前的问题中尝试了一些 jquery 示例,但我似乎无法使其工作。我构建 div 的方式是通过单击适用的标签来展开 p> 内容>。我想要一个搜索框,可以过滤掉不包含搜索框中列出的文本的 div。
<html>
<head>
</head>
<body>
<style>
div {
position: relative;
}
input[type=checkbox] {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
opacity: 0;
}
h3 {
font-size: large;
font-weight: 400;
color: #4a19ff;
margin: 20px 0 10px 0;
}
label {
cursor: pointer;
position: relative;
display: block;
padding-left: 20px;
font-family: 'Helvetica', 'Arial';
color: gray;
}
label:before {
display: none;
content: "";
position: absolute;
width: 0;
height: 0;
top: 40%;
left: 10px;
border-left: 8px solid black;
border-top: 8px solid transparent;
border-bottom: 8px solid transparent;
margin-top: -8px;
}
input[type=checkbox]:checked ~ h2 label:before {
border-left: 8px solid transparent;
border-top: 8px solid black;
border-right: 8px solid transparent;
margin-left: -4px;
margin-top: -4px
}
input[type=checkbox]:checked ~ h3 ~ p {
max-height: 80%;
color: white;
}
</style>
<center>
<input type="text" id="example" placeholder="Search example..">
</center>
<div class="code">
<input type="checkbox" id="1">
<h3>
<label for="1">1 Expandables</label>
</h3>
<p class="content">
This is an example of the expandables.
</p>
</input>
</div>
<div class="code">
<input type="checkbox" id="2">
<h3>
<label for="2">2 Test</label>
</h3>
<p class="content">
Can I do this?
</p>
</input>
</div>
<div class="code">
<input type="checkbox" id="3">
<h3>
<label for="3">3 Apology</label>
</h3>
<p class="content">
I am a noob at this and apologize if this is a basic request.
</p>
</input>
</div>
</body>
</html>
【问题讨论】: