html怎么实现像百度首页效果一样的背景图

发布时间:2020-10-22 14:41:14 作者:小新
来源:亿速云 阅读:112

小编给大家分享一下html怎么实现像百度首页效果一样的背景图,希望大家阅读完这篇文章后大所收获,下面让我们一起去探讨吧!

之前在百度知道我提问过这一个问题,后来解决了。不过好多人来问我时怎么解决的,源码。
其实很简单。这里我贴一下代码。有需要的小伙伴不用再加我qq了,直接来这里取吧。

里面的图片是我随便找的。

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title></title>
    <style>
    html,
    body {
        height: 100%;
    }
    body {
        margin: 0;
        background-repeat: no-repeat;
        background-size: cover;
        background-position: center;
        background-attachment: fixed;
        background-image: url(https://cache.yisu.com/upload/information/20200318/90/6823.jpg);
    }
    h2{
        height: 100%;
        width: 100%;
        margin: 0;
        padding: 0;
        color:#fff;
        background-color: rgba(0,0,0,0.5);
        display: -webkit-flex;
        display: -moz-flex;
        display: -ms-flex;
        display: -o-flex;
        display: flex;
        justify-content: center;
        align-items: center;
    }
    </style>
</head>
<body>
    <h2>按住Ctrl+滚动滚轮:可以看到文字缩放,背景不动</h2>
</body>
</html>

看完了这篇文章,相信你对html怎么实现像百度首页效果一样的背景图有了一定的了解,想了解更多相关知识,欢迎关注亿速云行业资讯频道,感谢各位的阅读!

推荐阅读:
  1. 百度首页html代码
  2. HTML制作百度首页

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

html

上一篇:Python shelve模块实现解析

下一篇:云服务器过期多久会被回收

相关阅读

您好,登录后才能下订单哦!

密码登录
登录注册
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》