固定消失滚动头部效果

代码语言:html

所属分类:视觉差异

下面为部分代码预览,完整代码请点击下载或在bfwstudio webide中打开

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>  Fixed Disappearing Scrolling Header</title>
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <style>
@font-face {
        font-family: 'Sucrose Bold Two';
        src: url("https://s3-us-west-2.amazonaws.com/s.cdpn.io/4273/sucrose.woff2") format("woff2");
    }
@font-face {
        font-family: 'IM Fell French Canon Pro';
        src: url("https://s3-us-west-2.amazonaws.com/s.cdpn.io/4273/im-fell-french-canon-pro.woff2") format("woff2");
    }
        * {
            box-sizing: border-box;
        }

        body {
            margin: 0;
        }

        header {
            background: url(https://s3-us-west-2.amazonaws.com/s.cdpn.io/4273/mountain-range.jpg) no-repeat;
            padding-top: 61.93333333%;
            background-size: cover;
            font-family: 'Sucrose Bold Two';
        }

        header img {
            position: absolute;
            top: 0;
            right: 0;
            width: 45.8%;
        }

        header h1 {
            position: fixed;
            top: 2rem;
            right: 2rem;
            font-size: 12vw;
            line-height: .8;
            margin-top: 0;
            text-align: center;
        }

        header h1 span {
            display: block;
            font-size: 8.75vw;
        }

        main {
            background: #fff;
            position: relative;
            border: 1px solid #fff;
            font-family: 'IM Fell French Canon Pro';
            font-size: 1.4rem;
            padding: 2rem 25%;
            line-height: 1.6;
        }

@media all and (max-width: 400px) {
            main {
                padding: 2rem;
            }
        }

    </style>
   .........完整代码请登录后点击上方下载按钮下载查看

网友评论0