What are some ways I can ensure my webpage remains consistent and user-friendly when scrolling, rather than appearing distorted and jumbled?

Is there a way to automatically scroll my page when the window is at a small height, instead of adjusting it to the height by squeezing it? I've tried using overflow in different ways, but haven't been successful in getting the entire page to scroll no matter where I place it. The codepen link can be found here: CODEPEN. Thank you for any help!

@import url('https://fonts.googleapis.com/css2?family=Press+Start+2P&display=swap');
@import url('https://fonts.googleapis.com/css2?family=Oleo+Script&display=swap');


* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    overflow-y: scroll;
}

a {
    color: #8524C6;
    text-decoration: none;
}

section {
    width: 100%;
    height: 100vh;
    color: #fff;
    background: linear-gradient(-45deg, #F5D0E4, #F6D5F2, #EAD5F6, #D9D5F6, #D5E1F6, #D5ECF6);
    background-size: 400% 400%;
    position: relative;
    animation: change 10s ease-in-out infinite;
    overflow: hidden;
    align-items: center;
    justify-content: center;
} 

h1 {
    display: flex;
    align-items: center;
    justify-content: center;
    color: #000;
    font-size: 1.3em;
    font-family: 'Oleo Script', cursive, 'Helvetica', sans-serif;
    letter-spacing: .07rem;
    transform: translateY(15vh);
}

h1 span {
    display: flex;
    text-align: center;
    vertical-align: middle;
}

h1:hover span {
    animation: animate .5s infinite;
}

@keyframes animate {
    0% {
        transform: translateY(0)
    }
    50% {
        transform: translateY(-30px)
    }
    100% {
        transform: translateY(0)
    }
}

h1 span:nth-child(1) {
    animation-delay: 0s;
}
h1 span:nth-child(2) {
    animation-delay: .1s;
}
h1 span:nth-child(3) {
    animation-delay: .2s;
}

h2 {
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    vertical-align: top;
    color: #000;
    font-size: .4rem;
    font-family: 'Press Start 2P', cursive, serif;
    text-transform: uppercase;
    transform: translateY(15.5vh)
}

.dancing-hamsters {
    display: flex;
    position: relative;
    margin: auto;
    align-content: center;
    width: 100%;
    height: 1.3rem;
    width: 5.1rem;
    transform: translateY(18vh);
    z-index: 1;
}

.container {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    background-color: #d3d3d3;
    align-content: center;
    position: absolute;
    top: 50%;
    bottom: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 50%;
    height: 50%;
    padding: 5px;
    padding-right: 3%;
    box-shadow: inset 0 0 10px #000;
}


.top-note {
    /* display: flex; */
    display: none;
    font-family: 'Helvetica', sans-serif;
    font-size: .65rem;
    text-align: center;
    justify-content: center;
    align-items: center;
    color: #000;
    transform: translate(4%, -5%);
}



.box {
    display: flex;
    flex-direction: column;
    background-color: #d3d3d3;
    text-align: center;
    justify-content: center;
    align-items: center;
    text-align: center;
    transform: translateX(50%);
    width: 1rem;
    height: 1rem;
    font-family: 'Press Start 2P', cursive, serif;
    font-size: .5rem;
    margin: 2rem;
}

img {   
    display: flex;
    width: 85%;
    height: 75%;
}

.container img {
    cursor: url('https://i.postimg.cc/6338xsj2/oie-nr-M8-Ct-Mr-SPb-H.png'), auto;
}

.box-text {
    margin-top: 10%;
    cursor: url('https://i.postimg.cc/6338xsj2/oie-nr-M8-Ct-Mr-SPb-H.png'), auto;
}

.nav {
    margin: auto;
    text-align: center;
    transform: translateY(70vh);
    font-size: .5rem;
    text-transform: uppercase;
    line-height: .8rem;
}

.nav a {
    color: #000;
    font-family: 'Press Start 2P', cursive, serif;
    text-shadow: 2px 2px 7px #8524C6;
}


footer {
    margin: auto;
    width: 100%;
    height: 1rem;
    font-family: Helvetica, sans-serif;
    font-size: .75rem;
    background-color: transparent;
    border-top: 1px solid #fff;
    text-align: center;
    padding-top: 1rem;
    bottom: 0;
    transform: translateY(80vh);
}

@keyframes change {
    0% {
        background-position: 0 50%;
    }
    50% {
        background-position: 100% 50%;
    }
    100% {
        background-position: 0 50%;
    }
}

/* Media Queries */

@media screen and (min-width: 740px) {

    h1 {
        font-size: 3em;
        transform: translateY(8vh);
        word-spacing: 2em;
    }

    h2 {
        font-size: 1rem;
        transform: translateY(8vh);
    }

    .dancing-hamsters {
        height: 2rem;
        width: 9rem;
        transform: translateY(10.5vh);
    }

    .container {
        display: flex;
        flex-direction: row;
        }

    .top-note {
        display: none;
    }

    .box {
        width: 15rem;
        height: 15rem;
        transform: translateX(15%);
        font-size: .75rem;
       }
    
    .img {
         width: 100%;
         height: 100%;
        }

    .nav li {
            margin: .5em;
            display: inline;
            text-align: center;
            align-items: center;
            justify-content: center;
            font-size: .85rem;
            }
    .nav {
        transform: translateY(64vh);
    }

    footer {
        transform: translateY(75vh);
    }
}

Answer №1

An efficient fix would be to incorporate the use of min-height in the primary section element:

section {
    width: 100%;
    height: 100vh;
    min-height: 500px; // Demonstrative addition of 500px
    color: #fff;
    background: linear-gradient(-45deg, #F5D0E4, #F6D5F2, #EAD5F6, #D9D5F6, #D5E1F6, #D5ECF6);
    background-size: 400% 400%;
    position: relative;
    animation: change 10s ease-in-out infinite;
    overflow: hidden;
    align-items: center;
    justify-content: center;
} 

While you've defined the section's height, integrating min-height ensures that your content won't shrink below the set value regardless of screen size.

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

What are some more efficient methods for implementing page location detection with Angular directives?

My website currently features a navigation bar with 4 anchor links that direct users to different sections of the page. As you scroll down the page, the corresponding link on the nav bar lights up to signify your position on the site. Experience it yourse ...

Insert image using AJAX

I am attempting to use Ajax to dynamically add an <img> element to a div on my webpage. The image's name needs to be fetched from a database. Although I have successfully added the <img> tag to the div and set the correct source (src) att ...

The background image is failing to display, although other styles for the class or element are visible

Why won't the background image display, even though I have verified that the image path is correct and changing other properties like color or background color works just fine? Here is my CSS code snippet: .container { background-imag ...

Guide to executing a batch file using electron

I've been struggling all morning to find a solution. I've gone through several tutorials, but I still can't wrap my head around how this should work. In my Electron app, there is a button that, when clicked, should execute a batch file (hpm ...

Interactions of selecting dates in datepicker widget

Currently, I am working on developing my personal work website. One issue I have encountered is with the calendar feature. The "From" date can be selected before today's date, which is not ideal. Additionally, if a date 5 days from now is chosen as th ...

Implementing a dynamic header image that adjusts its resolution based on the device and pixel density for

After finishing a design in Sketch, I have 3 unique layouts with header images displayed below: To ensure the height is consistent and to crop the image appropriately on different devices, I export the following images from Sketch: dog-header-mobile-1x.p ...

Issues have been reported regarding compatibility between iOS7, jquery.touchSwipe, on click and webkit-touch-callout

I'm in the process of developing a web application, but I've encountered an issue with iOS7 where there seems to be a conflict between jquery.touchSwipe and my "on click" events. Interestingly, the web app functions perfectly on older iOS versio ...

"Learn the trick to concealing a modal and unveiling a different one with the power of jquery

Whenever I try to open a modal, then click on a div within the modal in order to close it and open another one, I encounter an issue. The problem is that upon closing the first modal and attempting to display the second one, only the background of the seco ...

Animate.css plugin allows for owl-carousel to smoothly transition sliding from the left side to the right side

I have a question regarding the usage of two plugins on my website. The first plugin is Owl Carousel 2, and the second one is Animate.css. While using `animateIn: 'slideInLeft'` with Owl Carousel 2 is working fine, I am facing an issue with `ani ...

What is the process for modifying the design of an NPM package?

I may have a silly or incorrect question, but what exactly is the extent of default styling in an NPM package? If I am using an NPM package and wish to adjust the color of one of their elements, how should I go about it? In both my own index.css file and ...

Dependencies in Scala.js for CSS styling

I am currently having an issue implementing Scala.js with the bootstrap library. Including the js file was a simple and straightforward process: jsDependencies +="org.webjars" % "bootstrap" % "3.3.7-1" / "bootstrap.js" minified "bootstrap.min.js" However ...

Tips for creating CSS rules specifically for the default Android Browser using @media queries

Is there a CSS rule that can be applied only to the default Android Browser using @media queries? This rule should not affect Chrome, but only the default browser on Android devices. It's worth noting that there are numerous Android devices with vary ...

The floating label appears distorted when used with a datalist input in Bootstrap 5

How can I get the floating label to display correctly for datalists in Bootstrap 5? Currently, it looks like this... It's working fine without the form-floating class, but I want to use the floating form feature. <div class="form-floating" ...

I am struggling to find the right way to center those images

https://i.sstatic.net/aRkvl.jpg Hello everyone, I'm currently attempting to set up the main content of the homepage resembling the image provided, but I'm encountering some challenges. Every approach I take seems to cause the image to overflow ...

Use jQuery to replace this color with that color in CSS every time it appears

I have numerous div elements, some with a background-color: #aaa, others with font color: #aaa, and some with border-color: #aaa. There are also divs with various other colors. I am looking to update these colors (#aaa) to #ccc throughout the CSS. While ...

Unusual perspective of JSON with ng-jsoneditor in AngularJS

Currently, I have integrated ng-jsoneditor into my AngularJS application to display and format JSON data. I found guidance on how to implement this from both here and here. Here is the HTML code snippet: <div ng-jsoneditor="onLoad" ng-model="vm. ...

Chrome experiencing conflicts with backstretch when using multiple background images

In order to dynamically apply fullscreen background images in a WordPress site, I am utilizing Backstretch.js along with a custom field. Everything is functioning properly for the body's background image. However, there seems to be an issue with anot ...

Creating a circular text element with text both in the center and around the edges using CSS

I am attempting to recreate this image using CSS. Unfortunately, I haven't had success achieving those detailed edges with text. Is it feasible to accomplish this effect in CSS, and if so, what approach would be best? ...

Adjust the transparency of a navigation bar independently from the transparency of the text within the navigation bar

Seeking assistance on adjusting the opacity of this navbar without affecting the text within it. Any tips on changing the text color as well? <nav class="navbar navbar-expand-lg navbar-light bg-light"> <a class="navbar-brand" href="#" ...

PHP Implementing real-time dynamic categories

I am working on a project where there are multiple items listed with unique IDs. Each item has corresponding data with the same ID. I want to use JQuery, JScript, and PHP to display options based on the ID of the selected item in real-time. Below is a snip ...