在此页面上,悬停在文本上的div附加有幻灯片效果的文本,但问题是在效果之后,它的高度是不稳定的。我怎样才能固定高度?
index.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>script.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();
});
});
});发布于 2013-06-24 08:00:03
添加一个固定高度的样式标记。示例:将.append方法更改为:
append("<h3 style="height:100px">You're an idiot</h3>")https://stackoverflow.com/questions/17270510
复制相似问题