我有以下代码
.read-more-state {
display: none;
}
.read-more-target {
opacity: 0;
max-height: 0;
font-size: 0;
transition: .25s ease;
}
.read-more-state:checked ~ .read-more-wrap .read-more-target {
opacity: 1;
font-size: inherit;
max-height: 999em;
}
.read-more-state ~ .read-more-trigger:before {
content: 'Show more';
}
.read-more-state:checked ~ .read-more-trigger:before {
content: 'Show less';
}
.read-more-trigger {
cursor: pointer;
display: inline-block;
padding: 0 .5em;
color: #666;
font-size: .9em;
line-height: 2;
border: 1px solid #ddd;
border-radius: .25em;
}

<input type="checkbox" class="read-more-state" id="post-1" />
<div class="read-more-wrap"><?php echo substr($row_RS_Product['Full_Description'], 0, 500); ?>
<span class="read-more-target"><?php echo substr($row_RS_Product['Full_Description'], 500); ?></span></div>
<label for="post-1" class="read-more-trigger"></label>
&#13;
此代码的作用如下:
它显示前500个字符,直到到达第一个段落,然后显示文本的其余部分以及完整标记。
如果我删除内容如下:
<input type="checkbox" class="read-more-state" id="post-1" />
<div class="read-more-wrap"><?php echo substr($row_RS_Product['Full_Description'], 0, 500); ?> <span class="read-more-target"></span></div>
<label for="post-1" class="read-more-trigger"></label>
正确显示read-more-wrap的内容(前500个字符带有正确的标记)。然而,显然还有其他事情需要阅读更多内容。
将<span class="read-more-target">
更改为<div>
时,它几乎可以正常工作,但无论如何,这些词语都会分解,例如什么时候变成
wh
en