在这里,我创建了代码潘小提琴,以显示欢迎信息在我的主页。
我想让semitransparent attractive div with welcome smiley看看。它应该出现15秒,然后自动消失。
小提琴:链接到Codepan
问题:
任何帮助都是非常感谢的。
发布于 2013-11-28 06:37:48
您可以这样做,在15秒钟的页面加载之后,带有欢迎信息的笑脸就会消失。
<div id="d1" style="height:100px; width:100px; background-color:white">
<div id="mydiv" style="display:none">
<table>
<tr>
<td>
<canvas id="myDrawing" width="200" height="200" style="border:1px solid #EEE">
</canvas>
</td>
<td>
<p style="position:absolute; background-color:rgba(255,0,255,0.5);; filter:alpha(opacity=50); opacity:.5; padding:5px">
welcome to xyz.com!
Please review the site and give your valuable feedback.
</p>
</td>
</tr>
</table>
</div>
</div>JS
$( document ).ready(function() {
//var canvas = document.getElementById("myDrawing");
var a_canvas = document.getElementById("myDrawing");
var context = a_canvas.getContext("2d");
// Draw the face
context.fillStyle = "yellow";
context.beginPath();
context.arc(95, 85, 40, 0, 2*Math.PI);
context.closePath();
context.fill();
context.lineWidth = 2;
context.stroke();
context.fillStyle = "black";
// Draw the left eye
context.beginPath();
context.arc(75, 75, 5, 0, 2*Math.PI);
context.closePath();
context.fill();
// Draw the right eye
context.beginPath();
context.arc(114, 75, 5, 0, 2*Math.PI);
context.closePath();
context.fill();
// Draw the mouth
context.beginPath();
context.arc(95, 95, 17, Math.PI , 2*Math.PI,true);
context.closePath();
context.fill();
// Write "Hello, World!"
context.font = "20px Garamond";
context.fillText("welcome to xyz.com! ",15,175);
$( "#mydiv" ).fadeIn( 15000, function() {
$( "#myDrawing" ).fadeIn( 15000 );
});
}); 工作小提琴-到处玩
发布于 2013-11-28 06:13:41
使用Javascript .setInterval()函数执行以下操作:
$( document ).ready(function() {
window.setInterval(function(){
$( "#d1" ).fadeOut( "slow", function() {
//Do things when Animation is complete.
});
},15000);
});https://stackoverflow.com/questions/20258750
复制相似问题