As you're scrolling, an enigmatic white square suddenly materializes on the screen

    @import url("https://fonts.googleapis.com/css?family=Courgette|Roboto");
    * {
      box-sizing: border-box;
    }

    p {
      font-family: "Roboto", sans-serif;
      font-size: 1.25rem;
      line-height: 1.5;
    }

    blockquote {
      position: relative;
      padding-left: 1.5rem;
      font-family: "Courgette", serif;
      font-size: 2rem;
      line-height: 1.25;
      letter-spacing: -0.05rem;
    }
    blockquote:before {
      content: "";
      position: absolute;
      top: 0;
      left: 0;
      width: 6px;
      height: 100%;
      background-color: #A9DFBF;
      border-radius: 60px;
    }

    figure {
      display: flex;
      position: fixed;
      top: 0;
      left: 0;
      width: 100%;
      height: 100%;
      background-size: cover;
    }

    .hero {
      position: relative;
      width: 100vw;
      height: 100vh;
    }
    .hero:nth-child(1) figure {
      background-image: url("https://s3-us-west-2.amazonaws.com/s.cdpn.io/225363/photo-1506260408121-e353d10b87c7.jpg");
    }
    .hero:nth-child(2) figure {
      background-image: url("https://s3-us-west-2.amazonaws.com/s.cdpn.io/225363/photo-1506744038136-46273834b3fb.jpg");
    }
    .hero:nth-child(3) figure {
      background-image: url("https://s3-us-west-2.amazonaws.com/s.cdpn.io/225363/photo-1523712999610-f77fbcfc3843.jpg");
    }
    .hero:nth-child(4) figure {
      background-image: url("https://s3-us-west-2.amazonaws.com/s.cdpn.io/225363/photo-1501785888041-af3ef285b470.jpg");
    }

    .hero-inner {
      position: absolute;
      overflow: hidden;
      width: 100%;
      height: 100%;
      clip-path: polygon(0% 0%, 100% 0%, 100% 100%, 100% 100%, 0 100%);
    }


    .hero__title {
      display: flex;
      align-items: center;
      justify-content: center;
      position: fixed;
      top: 0;
      left: 0;
      padding: 0 1rem;
      width: 100%;
      height: 100%;
      color: white;
      font-family: "Courgette", serif;
      font-size: 8vw;
      letter-spacing: -0.125rem;
      text-align: center;
    }
    @media (min-width: 1200px) {
      .hero__title {
        font-size: 6rem;
      }
    }

    .content {
      position: relative;
      margin: 0 auto 8rem;
      padding: 2rem;
    }
    .content:before {
      content: "";
      display: block;
      position: absolute;
      top: -100px;
      left: 0;
      width: 100%;
      height: 100px;
      background-color: white;
      z-index: 99;
      -webkit-clip-path: polygon(50% 0%, 0% 100%, 100% 100%);
              clip-path: polygon(50% 0%, 0% 100%, 100% 100%);
    }

    .content__inner {
      margin: 0 auto;
      max-width: 700px;
    }
    .content__inner > * + * {
      margin-top: 1.5rem;
    }
    .content__inner > blockquote {
      margin: 3rem 0;
    }

    .content__title {
      font-family: "Courgette", serif;
      font-size: 3rem;
      line-height: 1.25;
      letter-spacing: -0.125rem;
      text-align: center;
    }
    @media (min-width: 600px) {
      .content__title {
        font-size: 4rem;
      }
    }

    .content__author {
      display: flex;
      align-items: center;
      justify-content: space-between;
      margin-bottom: 4rem;
      width: 100%;
      font-family: "Courgette", serif;
      font-size: 1.5rem;
      letter-spacing: -0.125rem;
      text-align: center;
    }
    .content__author:before, .content__author:after {
      content: "";
      flex: 1;
      height: 2px;
      background-color: #A9DFBF;
    }
    .content__author:before {
      margin-right: 1rem;
    }
    .content__author:after {
      margin-left: 1rem;
    }
    <!DOCTYPE html>
    <html lang="en" >
    <head>
      <meta charset="UTF-8">
      <meta name="viewport" content="width=device-width, initial-scale=1">
    </head>
    <body>
    <section class="hero">
      <div class="hero-inner" id="section-0">
        <figure></figure>
        <h2 class="hero__title">Explore our world</h2>
      </div>
    </section>
    <section class="hero">
      <div class="hero-inner" id="section-1">
        <figure></figure>
        <h2 class="hero__title">View all its beauty</h2>
      </div>
    </section> 
    </body>
    </html>

view a visual representation here

The layout renders well on desktop browsers but displays incorrectly on mobile devices due to an unwanted square shape that appears. This issue seems to be related to the clip-path property, which I'm struggling to resolve. The presence of this square disrupts the overall design and user experience especially on mobile platforms where it's more noticeable. Seeking assistance in fixing this problem from those knowledgeable in CSS intricacies. Thank you for any guidance or suggestions provided.

Answer №1

I suggest adjusting the height of your sections in HTML.

For example, you can set:

max-height: whatever you want in viewport height
min-height: minimum required height for your section

I recommend the following:

 .hero {
      position: relative;
      width: 100vw;
      min-height: 100vh !important;
    }

This ensures that the view will be at least 100vh and using !important emphasizes its importance to the browser.

Since this primarily impacts mobile views, consider placing this code within a media query (such as 600px). Test it on both to determine which one yields results.

Good luck with your project!

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Conceal an element within the initial row of the table

Below is the table structure: <table id="mytable"> <tr> <td>name</td> <td> <a id="button1" class="button">link</a> </td> </tr> <tr> <td>name2</td> ...

Issues with CSS not being applied when the page content exceeds the viewport

<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width,initial-scale=1"> <title>Unique Title</title> <style> #div1 { posit ...

JavaScript Deviance

I am facing an issue with my JS code while trying to send form data to a .php file via AJAX. The problem occurs when the input fields are filled - for some reason, my client-side page refreshes and the php file does not get executed. However, everything wo ...

Developing a new class within a function

In this section of the HTML file, I have set up a form to collect email and password information from new users in order to create a new profile: <form name="userInfo"> <fieldset> <legend>Create a new account</legend> ...

bootstrap for building responsive websites

I am trying to modify the width of an input from 100% to 50%, and position it in the center of the page so that it remains responsive when resizing the browser window. <!DOCTYPE html> <html> <head> <title>test</title&g ...

Which JQuery plugins can transform regular <select> dropdowns into more stylish options?

After an extensive search, I was only able to locate one solution at this link. I scoured the entire internet for alternatives. ...

Transform the scrollbar appearance on hover. Implement this feature using React and CSS with Material-UI

Within my React app, I am facing an issue with a scrollbar appearing in multiple lists. The global CSS being used within Material-UI is as follows: MuiCssBaseline: { ...theme.overrides?.MuiCssBaseline, '@global': { '@font-fa ...

Angular: Disabling a button based on an empty datepicker selection

Can anyone help me figure out how to disable a button when the datepicker value is empty? I've tried using ngIf to check if the datepicker is empty and then disable the button, but it's not working. My goal is to make the button unclickable if th ...

There are no errors with PHP and it fails to insert any entries into the database

I am struggling to save secq (secret question) and seca (secret answer) in the database. Even though I don't encounter any errors during the registration process, the values of the variables are successfully passed through POST when echoed. Despite ...

Creating a div background that is transparent within a Bootstrap modal

Here is the HTML (Bootstrap) code I have: <div modal="showModal" close="cancel()"> <div class="modal-header text-center"> <h2>Members who shortlisted you </h2> </div> <div class="modal-body"> ...

Unable to generate dynamic HTML through AJAX request

I made an Ajax API call and received the response in JSON format. I need to create dynamic HTML to display each value in HTML elements. I tried getting the response from the API but couldn't generate the HTML. Can someone assist me with this? Also, I ...

The issue with IE-9 is that it is mistakenly picking up the placeholder value as

My HTML code looks like this: <input id="SLOCriteriaOtherText" name="SLOCriteriaOtherText" style="width: 100%;" type="text" data-role="autocomplete" placeholder="Enter name for 'other' metric..." class="k-input" autocomplete="off" role="textb ...

Tips for showing images with the full path URL retrieved from JSON using AngularJS

I am currently working on a project that involves displaying images from a JSON file. The URLs of these images are stored in the JSON file. Currently, my code is only outputting the URLs themselves, which is expected. However, I am looking for a way to act ...

Identifying Flash content in a unique way

In my dynamic page (let's call it myFlashContainer.jsp), the Flash content changes based on the link that is clicked. The code responsible for rendering the Flash looks like this: <object height="100%" align="l" width="100%" id="player" codebase= ...

Every single image within a specific domain

Exploring a way to create a gallery showcasing all the images within my domain's internet root folder. These images are scattered across various folders. What is the most efficient method to navigate through these folders and display the images? ...

Customizing the field_error_proc in Rails is causing issues with the HTML layout

Within a rails application, I have customized the field_error_proc to enable inline error displays as shown below: https://i.sstatic.net/DjmdN.png The code snippet for achieving this functionality is outlined here: ActionView::Base.field_error_proc = pr ...

Is it possible to nest an HTML <span> inside a label tag in a Rails form_for?

Is it possible to nest a span element inside a form_for label tag? I am trying to achieve this in order to style a specific part of the label using CSS, such as making the text red. While it seems like valid HTML based on my research, it is causing some is ...

Retrieve the HTML code from a file and store it in a JavaScript variable

My PhoneGap application is able to load an external page in the inAppBrowser and inject a bottom bar onto that page using executeScript(). This allows me to have a bar with basic controls on the specific page. I have successfully implemented this functiona ...

Update the central information while keeping the entire webpage intact

Hey there, I could really use some assistance! I'm working on a software documentation website that is similar to the mongodb documentation page. It has a header, sidebar (navbar menu), and main content area. Within the sidebar navbar menu, I have dr ...

Display various JavaScript function outputs in an HTML table for convenient tracking

Thanks to a helpful user on this platform, I was able to capture data from a JavaScript function and display it in an html table. However, I now have another query. How can I execute the function multiple times during page load and record the results in ...