【发布时间】:2018-05-26 03:28:57
【问题描述】:
我正在使用 tinyMCE,一个允许用户创建博客的文本编辑器。这可以包括页面上任何位置的文本、图像、中断等。输出有 HTML 标签。
我正在寻找一种方法来首先显示页面的一部分,并在最后显示一个“显示更多”按钮以供点击,然后再显示页面的其余内容。
我知道如何为文本内容创建一个 javascript 显示/隐藏函数,但我的问题是如何为第一部分(初始显示)和第二部分(其余内容)找到此中断的位置,因为我只能在 HTML 必须有效的地方打破它。
或者有没有办法允许整个内容,但只是通过某种类型的 CSS 在视觉上隐藏一部分内容?
一些初步的方向将不胜感激!
编辑:我会考虑使用“strtok”php 命令来获取第一段并仅显示它,但是,它似乎不起作用。举个例子:
$mystring = <<<EOF
<div>
<h2>Why do we use it?</h2>
<p>It is a long established fact that a reader will be
distracted by the readable content of a page when looking at its layout.
The point of using Lorem Ipsum is that it has a more-or-less normal
distribution of letters, as opposed to using 'Content here, content here',
making it look like readable English. Many desktop publishing packages and
web page editors now use Lorem Ipsum as their default model text, and a search
for 'lorem ipsum' will uncover many web sites still in their infancy.
Various versions have evolved over the years, sometimes by accident,
sometimes on purpose (injected humour and the like).<img style="float:
left; margin: 10px;" title="DSC00286.JPG" src="images/images91/imageID1527306461424.jpg"
alt="" width="200" height="154" /></p><p>test test test</p>
</div>
<div>
<h2>Where does it come from?</h2>
EOF;
$partialString = strtok($mystring, '</p>');
echo $partialString;
THE RESULT IS: div
如果有人能指出,可能会遗漏一些简单的东西?
【问题讨论】:
-
您可以只使用隐藏溢出的 css 框高度,而不必弄乱拆分 html。然后在你的显示更多按钮上,只需从 css 中溢出,它就会自动展开到全高。
标签: javascript php html css tinymce