在这个页面上,悬停在一个文本上会附加一个带有幻灯片效果的文本的div,但问题是效果后它的高度不稳定。如何固定高度?
索引.html
<!DOCTYPE html>
<html>
<head>
<script src = "http://code.jquery.com/jquery-1.10.1.min.js" type = "text/javascript"></script>
<script src = "script.js" type = "text/javascript"></script>
</head>
<body>
<div>
<h1 style = "width: 299px" id = "text1">Hover to see the truth</h1>
</div>
</body>
</html>
脚本.js
$(document).ready (function() {
$(document).on ("mouseenter", "#text1", function() {
$("body").append ("<div style = 'background-color: red; width: 299px' id = 'descr'></div>");
$("#descr")
.hide()
.append ("<h3>You're an idiot</h3>")
.slideDown ("slow");
});
$(document).on ("mouseleave", "#text1", function() {
$("#descr").slideUp ("slow", function() {
$(this).remove();
});
});
});