我想显示/隐藏段落的一部分如下:
就像我想的那样,像这样的事情能起作用吗?
<div class="partial-text"><a href="">► This is the start of the paragraph with <style=”fadingCSS”> fading text</style></a></div>
<div class="full-text"><a href="">▼ This is the start of the paragraph with fading text no longer fading and the rest of the content shown.</a></div>我需要帮助
我看过以下几点,但不能把它们拼凑在一起:
这是我力所能及的,所以如果有人愿意帮忙,我会非常感激的!
发布于 2020-01-31 17:10:18
<details>标记不是一个结构性的HTML元素,所以我认为不可能用它黑出您想要的东西。
使用复选框和兄弟姐妹选择器的这里有一个实现 (众多的)缺点之一是,您必须同时定义摘要和整个段落。不过,这类或类似的CSS应用程序并不是我推荐的。它们不是很容易扩展,依赖于特定的HTML结构,如果它们没有很好的文档化,就很难理解。
发布于 2020-01-31 21:03:18
好吧,为了我的目的,我已经做得很好了。我不得不修改eMontilG的代码,因为它没有对WordPress“友好”。下面是密码。
HTML
<label class="show-hide">
<input type="checkbox" class="input-checkbox"/>
<span class="less-text">
►This is the start of the paragraph with fading text...
</span>
<span class="more-text">
▼This is the start of the paragraph with fading text no longer fading and the rest of the content shown.
</span>
</label>CSS
.show-hide {
display: flex;
}
.input-checkbox {
display: none;
}
.less-text {
display: block;
}
.more-text {
display: none;
}
.input-checkbox:checked ~ .less-text {
display: none;
}
.input-checkbox:checked ~ .more-text {
display: block;
}
.input-checkbox:not(:checked) ~ .less-text {
display: block;
}
.input-checkbox:not(:checked) ~ .more-text {
display: none;
}正如eMontilG正确指出的那样,我知道这不是“非常可扩展的并且依赖于特定的HTML结构”,但是它是有效的。
https://stackoverflow.com/questions/60006359
复制相似问题