淡出起始页

Fade Out Splash Page

本文关键字:起始页 淡出      更新时间:2023-09-26

我正试图在我创建的初始页面上创建一个淡出,该页面将融入我的网站主页。我的网站是:http://www.simonsamuel.com/

我使用的jQuery代码是:

<script type="text/javascript">
    $("#splash").click(function() {
        $("#splash").fadeOut("slow");
    });
</script>

这是CSS代码:

#splash {
    background-color: #ffffff;
    background-image: url(http://i.imgbox.com/Al4c3tZ5.png);
    background-position: center;
    background-repeat: no-repeat;
    position: fixed;
    top: -60px; 
    right: 0; 
    bottom: 0; 
    left: 0;
    z-index: 99999;
}

我尝试了许多不同的代码,但找不到适用于我的网站的代码。出于好奇,我想知道是否可以用jQuery更改网页标题?我想把标题栏做成大写字体。

非常感谢您的帮助,谢谢!

当我查看您的源代码时,我看到的是:

<br />
$(document).ready(function() {<br />
    $('#splash').click(function() {<br />
        $('#splash').fadeOut(2000);<br />
    });<br />

为什么代码中有换行符?那是html代码。

此外,你的代码是不完整的

$(document).ready(function() {
    $('#splash').click(function() {
       $('#splash').fadeOut(2000);
    }); // forgot these
}); // or these

我设置了一个小提琴来演示基础知识-http://jsfiddle.net/jayblanchard/nBdkU/

$(document).ready(function () {
    $('#splash').css('opacity', '0.5'); // doing this with jQuery for ease
    // here are the basics, just like your existing code
    $("#splash").click(function () {
        $("#splash").fadeOut("slow"); // you could also use $(this).fadeOut('slow');
    });
});

在加载页面时查看控制台时,我遇到了一个语法错误,该错误与@Puzzle84指出的问题相同——

<script type="text/javascript"><br />
$(document).ready(function() {<br />
$('#splash').click(function() {<br />
    $('#splash').fadeOut(2000);<br />
  });<br />
</script>

所有这些断线都需要删除。然后,正如他所指出的,你需要另一组括号(}))。当我点击splash元素时,它就会消失,你的网站就会显示出来。如果你想在splash元素中显示一些东西,你只需要为它们设置正确的CSS位置。

控制台中还指出了其他错误(未定义Cargo.View.Main)

对于标题位,你可以做一些纯JavaScript或一点jQuery-

document.title = 'the page title'; // changes the title
document.title.toUpperCase(); // sets title to upper case
$(document).attr('title', 'the page title'); // changes the title
$(document).attr('title').toUpperCase(); // sets to upper case