试图做出一个响应的div

时间:2017-02-03 18:23:36

标签: html css

我无法制作响应式文字' W E L C O M E'。我尝试了媒体查询,但我没有。我的HTML和CSS代码在一个片段中,试图在这里运行它,但也有一些问题。

正如你所看到的那样,有一些带有动画的文字,必须以这种方式完成,用单个字母作为' li'



#bg1 {
    background: url(img/38890540-cosmic-pictures-wallpapers.jpg) no-repeat center center fixed;
    -webkit-background-size: cover;
    -moz-background-size: cover;
    -o-background-size: cover;
    background-size: cover;
}

#bg2 {
    background-color: darkgray;
}

#bg3 {
    background-color: darkgreen;
}

#bg4 {
    background-color: darkslateblue;
}

.fly-in-text {
    list-style: none;
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translateX(-50%) translateY(-50%);
}

.fly-in-text li {
    display: inline-block;
    margin-right: 50px;
    font-family: Quicksand, sans-serif;
    font-weight: 300;
    font-size: 4em;
    color: #fff;
    opacity: 1;
    transition: all 2.5s ease;
}

.fly-in-text li:last-child {
    margin-right: 0;
}

.fly-in-text.hidden li {
    opacity: 0;
}

.fly-in-text.hidden li:nth-child(1) {
    transform: translateX(-200px) translateY(-200px);
}

.fly-in-text.hidden li:nth-child(2) {
    transform: translateX(20px) translateY(100px);
}

.fly-in-text.hidden li:nth-child(3) {
    transform: translateX(-150px) translateY(-80px);
}

.fly-in-text.hidden li:nth-child(4) {
    transform: translateX(10px) translateY(-200px);
}

.fly-in-text.hidden li:nth-child(5) {
    transform: translateX(-300px) translateY(200px);
}

.fly-in-text.hidden li:nth-child(6) {
    transform: translateX(20px) translateY(-20px);
}

.fly-in-text.hidden li:nth-child(7) {
    transform: translateX(30px) translateY(200px);
}

<!doctype html>
<html>

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <link rel="stylesheet" type="text/css" href="css/jquery.fullPage.css">
    <link href="https://fonts.googleapis.com/css?family=Quicksand" rel="stylesheet">
    <link rel="stylesheet" type="text/css" href="css/styles.css">
    <title>x</title>
</head>

<body>

    <div id="fullpage">
        <div class="section" id="bg1">
            <ul class="fly-in-text hidden">
                <li>W</li>
                <li>E</li>
                <li>L</li>
                <li>C</li>
                <li>O</li>
                <li>M</li>
                <li>E</li>
            </ul>

        </div>

        <div class="section" id="bg2"></div>
        <div class="section" id="bg3"></div>
        <div class="section" id="bg4"></div>
    </div>

    <div class="section">
        <div class="slide">Slide 1</div>
        <div class="slide">Slide 2</div>
        <div class="slide">Slide 3</div>
        <div class="slide">Slide 4</div>
    </div>
    <script src="js/jquery-3.1.1.min.js"></script>
    <script src="js/jquery.fullPage.min.js"></script>
    <script type="text/javascript">
        $(document).ready(function () {
            $('#fullpage').fullpage();
        });

        $(function () {
            setTimeout(function () {
                $('.fly-in-text').removeClass('hidden');
            }, 500);
        })
    </script>
</body>

</html>
&#13;
&#13;
&#13;

1 个答案:

答案 0 :(得分:0)

尝试使用font-size

设置vw

示例:https://jsfiddle.net/91fmerzf/

当您调整帧大小时,您可以看到在动画之后它总是以一行结束。