单击生成器按钮后,如何让div的底部保持固定?

时间:2017-11-15 20:42:27

标签: jquery html css

这是我的代码

HTML

<head>  
<link 
href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-
awesome.min.css" 
rel="stylesheet"  type='text/css'>  
<h1 style="text-align: center; color: red; font-family: verdana; font-
weight: bold;">WHAT CHRISTMAS MOVIE SHOULD I WATCH?</h1>
</head>
<body>
<div class="container">
<div id="generator" style="padding-top: 10px;">
<p>
<i class="fa fa-snowflake-o fa-5x spin"></i>
<i class="fa fa-gift fa-5x spin"></i>
<i class="fa fa-tree fa-5x spin"></i>

</p>

<input type="button" id="btnSearch" value="What Christmas Movie Should I 
Watch?" onclick="GetValue();" />
<p id="message"></p>
</div>
</div>
</body>

JQUERY

function GetValue()
{
var myarray= new Array("The Santa Claus","Just Friends","Home Alone", "Home 
Alone 2","Serendipity","Love Actually","Elf","Christmas Vacation","A  
Story","The Grinch","Jingle All the Way","Rudolph the Red-Nosed 
Reindeer","Ernest Saves Christmas","Frosty the Snowman","The Muppet 
Christmas Carol","The Nightmare Before Christmas","Jesus of Nazareth 
1977","Bad Santa");
var random = myarray[Math.floor(Math.random() * myarray.length)];
//alert(random);
document.getElementById("message").innerHTML=random;
}

https://codepen.io/McComb/pen/qVPOQO

单击按钮,查看div底部如何更改框形状。我该如何避免这种情况?我只想让盒子的底线保持固定。我愿意接受不同的解决方案。也许是占位符文字?

1 个答案:

答案 0 :(得分:1)

在生成器div上设置高度和最大高度:

#generator {
  height: 250px;
  max-height: 250px;
}