【问题标题】:Overlapping sections, the content of section goes beyond this section重叠部分,部分内容超出本部分
【发布时间】:2017-12-05 21:44:52
【问题描述】:

我有问题:第一部分 - 标题是附件固定,当我缩小浏览器窗口时,背景只覆盖了一小部分部分,其余内容在另一个部分下,或者完全超出背景.正如您将看到的,只有将此页面打开到全屏才能解决问题,并且这些部分看起来正确。相比之下,减小窗口会导致该部分分崩离析并跳过另一个。原因可能是缺少clearfixes,还是每个部分没有定位?

https://codepen.io/tubaris/pen/YQQewB/

`<html lang="pl">
<head>
    <meta charset="UTF-8">
    <meta name="description" content="Omnifood">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Omnifood</title>
    <link rel="stylesheet" type="text/css" href="vendors/css/style.css">
    <link rel="stylesheet" type="text/css" href="vendors/css/ionicons.min.css">
    <link href="https://fonts.googleapis.com/css?family=Lato:100,300,400&amp;subset=latin-ext" rel="stylesheet">
</head>   
<body>
    <header>
        <nav>
            <div class="row">
                <img src="https://image.ibb.co/bY2jyQ/logo_white.png" alt="Omnifood logo" class="logo">
                <ul class="main-nav">
                    <li><a href="#">Food delivery</a></li>
                    <li><a href="#">How it works</a></li>
                    <li><a href="#">Our cities</a></li>
                    <li><a href="#">Sign up</a></li>
                </ul>
            </div>
        </nav>       
        <div class="header-text-box">
            <h1>Goodbye junk food.<br>Hello super healthy meals.</h1>
            <a href="#" class="btn btn-coloured">I’m hungry</a>
            <a href="#" class="btn btn-bordered">Show me more</a>
        </div>
    </header>
    <section class="section-features">
        <div class="row">
            <h2>Get food fast &ndash; not fast food.</h2>
            <p class="text-about">Hello, we're Omnifood, your new premium food delivery service. We know you're always busy. No time for cooking. So let us take care of that, we're really good at it, we promise!</p>
        </div>
        <div class="row">
            <div class="feature-col">
                <i class="ion-clock icon-big"></i>
                <h3>Up to 365 days/year</h3>
                <p>Never cook again! We really mean that. Our subscription plans include up to 365 days/year coverage. You can also choose to order more flexibly if that's your style.</p>
            </div>
            <div class="feature-col">
                <i class="ion-jet icon-big"></i>
                <h3>Ready in 20 minutes</h3>
                <p>You're only twenty minutes away from your delicious and super healthy meals delivered right to your home. We work with the best chefs in each town to ensure that you're 100% happy.</p>
            </div>
            <div class="feature-col">
                <i class="ion-ios-nutrition icon-big"></i>
                <h3>100% Organic</h3>
                <p>All our vegetables are fresh, organic and local. Animals are raised without added hormones or antibiotics. Good for your health, the environment, and it also tastes better!</p>
            </div>
            <div class="feature-col">
                <i class="ion-card icon-big"></i>
                <h3>Order anything</h3>
                <p>We don't limit your creativity, which means you can order whatever you feel like. You can also choose from our menu containing over 100 delicious meals. It's up to you!</p>
            </div>
        </div>
    </section>
    <section class="section-meals">
        <div class="row">
            <h2>Omnifood meals showcase</h2>
            <p class="text-about">Selected Omnifood meals offered by our company</p>
        </div>
        <ul class="meals-showcase">
            <li>
                <figure class="meal-photo">
                <img src="https://preview.ibb.co/eTtwCk/1.jpg" alt="egg with vegetables">
                </figure>
            </li>
            <li>
                <figure class="meal-photo">
                <img src="https://image.ibb.co/iFpgdQ/2.jpg" alt="california rolls sushi">
                </figure>    
            </li>
            <li>
                <figure class="meal-photo">
                <img src="https://preview.ibb.co/igwGCk/3.jpg" alt="asparagus with carrots and meat">
                </figure>   
            </li>
            <li>
                <figure class="meal-photo">
                <img src="https://preview.ibb.co/h74sk5/4.jpg" alt="carrot soup with nuts">
                </figure>
            </li>
        </ul>
        <ul class="meals-showcase">
            <li>
                <figure class="meal-photo">
                <img src="https://preview.ibb.co/j4MuyQ/5.jpg" alt="steak with green beans">
                </figure>
            </li>
            <li>
                <figure class="meal-photo">
                <img src="https://image.ibb.co/m8twCk/6.jpg" alt="roll with egg, rucola and radish">
                </figure>
            </li>
            <li>
                <figure class="meal-photo">
                <img src="https://preview.ibb.co/bBjEyQ/7.jpg" alt="healthy burger">
                </figure>
            </li>
            <li>
                <figure class="meal-photo">
                <img src="https://preview.ibb.co/fNWisk/8.jpg" alt="oatmeal with strawberries and cherries">
                </figure>
            </li>
        </ul>
    </section>
    <section class="section-steps">
        <div class="row">
            <h2>How it works &ndash; Simple as 1, 2, 3</h2>
        </div>
        <div class="row">
            <div class="steps-col1">
                <img src="https://image.ibb.co/hHoeXk/app_i_Phone.png" alt="Omnifood app on iPhone" class="app-screen">
            </div>
            <div class="steps-col2">
                <div class="works-step">
                    <div>1</div>
                    <p>Choose the subscription plan that best fits your needs and sign up today.</p>
                </div>
                <div class="works-step">
                    <div>2</div>
                    <p>Order your delicious meal using our mobile app or website. Or you can even call us!</p>
                </div>
                <div class="works-step">
                    <div>3</div>
                    <p>Enjoy your meal after less than 20 minutes. See you the next time!</p>
                </div>
                <a href="#" class="btn-app"><img src="https://image.ibb.co/gyPxJQ/download_app.png" alt="app store button"></a>
                <a href="#" class="btn-app"><img src="https://image.ibb.co/jZWYsk/download_app_android.png" alt="play store button"></a>
            </div>
        </div>
    </section>
</body>

`

【问题讨论】:

    标签: html css view positioning clearfix


    【解决方案1】:

    我假设您要问的是为什么您的.features-col div 被切断了。

    原因是,.features-col div 被从文档的主流中取出,并没有扩展.section-features div。这是由于 float: left 属性。删除该属性后,您可以立即看到这些列展开了父 div。

    另一种让列与页面左侧对齐的方法是将.row 类设置为窗口宽度的100%,然后设置text-align: left

    【讨论】:

    • 嗯,我不明白,你的建议对我不起作用。我只需要标题部分为 100% vh。每个下一部分都应具有页面内容指定的高度。为每个部分的内容确定其高度,则不会拉伸列,整个部分将在列后面结束。我不知道为什么我的所有部分都是 100vh,当我降低浏览器高度时,所有部分背景都会被剪切
    【解决方案2】:

    使.meal-photo 类向左浮动。 即将float:left 添加到您的CSS 代码中的.meal-photo 类。

    【讨论】:

      猜你喜欢
      • 2017-11-04
      • 1970-01-01
      • 1970-01-01
      • 2019-10-29
      • 2019-02-23
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多