dongniuxia8650 2013-09-04 12:58
浏览 31

CSS - 加载页面时的网站覆盖[关闭]

Im setting up a website with a different navigation structure compared to whats traditional, and i want to add a overlay on top of the site which is loaded when the user enters the site the first time.

The overlay should be fullscreen, black "opacity=50", and im going to add simple text about how to use the website. It should also go away when klicking

Im a web designer, and i have limited knowledge in coding. (some css/html/php)

Is there a simple way to add a class for this?

Thanks for feedback

  • 写回答

3条回答 默认 最新

  • dougudu3564 2013-09-04 13:05
    关注

    Google it! It's not hard. A very quick Google search brought me here:

    $(function() {
        var docHeight = $(document).height();
        $("body").append("<div id='overlay'></div>");
        $("#overlay").height(docHeight).css({
            'opacity' : 0.4,
            'position' : 'absolute',
            'top' : 0,
            'left' : 0,
            'background-color' : 'black',
            'width' : '100%',
            'z-index' : 5000
        });
    });
    

    To close the overlay by clicking anywhere you can do the following:

    $('#overlay').click(function (e) {
        this.remove();
    });
    

    Here's a jsFiddle to demonstrate.

    评论

报告相同问题?

悬赏问题

  • ¥20 win11修改中文用户名路径
  • ¥15 win2012磁盘空间不足,c盘正常,d盘无法写入
  • ¥15 用土力学知识进行土坡稳定性分析与挡土墙设计
  • ¥70 PlayWright在Java上连接CDP关联本地Chrome启动失败,貌似是Windows端口转发问题
  • ¥15 帮我写一个c++工程
  • ¥30 Eclipse官网打不开,官网首页进不去,显示无法访问此页面,求解决方法
  • ¥15 关于smbclient 库的使用
  • ¥15 微信小程序协议怎么写
  • ¥15 c语言怎么用printf(“\b \b”)与getch()实现黑框里写入与删除?
  • ¥20 怎么用dlib库的算法识别小麦病虫害