【发布时间】:2017-02-10 15:17:04
【问题描述】:
我有这个div,它的内容来自jquery append():
每次文本长度达到 div 宽度的末尾时,文本将继续并更改 div 的高度。
但我想保持 div 的高度并隐藏以前的文本。另外,我有一个带渐变的 PNG,当 jquery append 检测到 div 已满是文本时,我想将 png 图像放在左侧。
预期结果:
我已经尝试过什么:
- https://www.sitepoint.com/community/t/how-do-you-put-a-div-without-causing-a-new-line-break/7398/8
- No Line Break With jQuery .append()
我当前的代码(javascript):
$.post(base_url + "ajax/validate_answer", {'quiz': load, 'answer': answer}, function (data) {
/* if incorrect answer */
if (data.answer_details.correct === false)
{
$("." + current_did).css("color", "#D05555");
}
/* append text with a new word */
$(".dictionary-stack").append(' • • • <span class="' + data.next_quiz.display.dictionary.did + '">' + data.next_quiz.display.dictionary.ja_kanji + ' ' + data.next_quiz.display.dictionary.ja_roman + ' [' + data.next_quiz.display.dictionary.en_roman + ']</span>');
}
CSS 到容器(.dictionary-stack):
.dictionary-stack
{
position: absolute;
bottom:100px;
width:100%;
display: block;
background:#E6E6E6;
padding: 20px;
color:#333333;
}
我该怎么做?
谢谢。
【问题讨论】:
-
您可能对这个问题投了反对票,因为它没有显示对该问题的任何研究工作。请提供您编写的代码以及您遇到的特定技术问题的具体问题。
-
问题已编辑,谢谢。
标签: javascript jquery html css