When enlarging or extending the container, text starts to spill out

My issue is that the text content is overflowing the designated box or container - any ideas on how to fix this problem?

I have attempted to utilize max-width and max-height, but unfortunately, I am unable to get them to function as intended.

Here's a snippet of the HTML structure:

<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Product Landing</title>
    <link rel="stylesheet" href="product landing.css">
</head>
<body>
    <main class="main-container">
        <nav class="navbar-container">
            <img src="logo.svg" class="logo-img">
            <ul class="navbar">
                <li class="select-items"><a href="#">Features</a></li>
                <li class="select-items"><a href="#">Testimonials</a></li>
                <li class="select-items"><a href="#">Pricing Table</a></li>
            </ul>
        </nav>
        <section class="features">
            <h1>The Advantages</h1>
            <p>Lorem ipsum dolor sit amet consectetur adipisicing elit.
                 Illum temporibus minima et ab aliquid</p>
            <ul class="boxs">
                <li>
                    <h2>GPS Tracking</h2>
                    <p>Lorem ipsum dolor sit amet consectetur adipisicing elit.
                    Illum temporibus minima et ab aliquid, enim veniam. Explicabo 
                    eius non ea magni itaque aspernatur distinctio voluptatem minima,
                    est, dolorem consectetur! Dolorem?</p>
                </li>
                <li>
                    <h2>Heartbeat Analysis</h2>
                    <p>Lorem ipsum dolor sit amet consectetur adipisicing elit.
                    Illum temporibus minima et ab aliquid, enim veniam. Explicabo 
                    eius non ea magni itaque aspernatur distinctio voluptatem minima,
                    est, dolorem consectetur! Dolorem?</p>
                </li>
                <li>
                    <h2>Prioritizing Security</h2>
                    <p>Lorem ipsum dolor sit amet consectetur adipisicing elit.
                    Illum temporibus minima et ab aliquid, enim veniam. Explicabo 
                    eius non ea magni itaque aspernatur distinctio voluptatem minima,
                    est, dolorem consectetur! Dolorem?</p>
                </li>
                <li>
                    <h2>Innovative Concepts</h2>
                    <p>Lorem ipsum dolor sit amet consectetur adipisicing elit.
                    Illum temporibus minima et ab aliquid, enim veniam. Explicabo 
                    eius non ea magni itaque aspernatur distinctio voluptatem minima,
                    est, dolorem consectetur! Dolorem?</p>
                </li>
                <li>
                    <h2>Cost-Saving Strategies</h2>
                    <p>Lorem ipsum dolor sit amet consectetur adipisicing elit.
                    Illum temporibus minima et ab aliquid, enim veniam. Explicabo 
                    eius non ea magni itaque aspernatur distinctio voluptatem minima,
                    est, dolorem consectetur! Dolorem?</p>
                </li>
                <li>
                    <h2>Proven Solutions</h2>
                    <p>Lorem ipsum dolor sit amet consectetur adipisicing elit.
                    Illum temporibus minima et ab aliquid, enim veniam. Explicabo 
                    eius non ea magni itaque aspernatur distinctio voluptatem minima,
                    est, dolorem consectetur! Dolorem?</p>
                </li>
            </ul>
        </section>
        <section class="testimonials"></section>
        <section class="pricing"></section>
    </main>
</body>
</html>

Now let's take a look at some CSS styling options:

body {
    padding: 0;
    margin: 0;
    width: 100%;
    height: 100%;
    font-family: Arial, Helvetica, sans-serif;
    box-sizing: border-box;
}

.main-container {
    background-color: brown;
    width: 100%;
    height: 100%;
    padding: 0;
    margin: 0;
}

nav {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    background-color: blueviolet;
}

.logo-img {
    margin-right: auto;
}

.navbar > li {
    display: inline-block;
    margin: 0px 10px;
    padding: 5px 10px;
    text-align: center;
}

Incorporate these properties for additional control over your layout elements:

.navbar > :nth-child(3) {
    color: aquamarine;
    background-color: cornflowerblue; 
    border: 2px solid cornflowerblue;
    padding: 5px 5px;
    border-radius: 50px;
}
.navbar > li > a {
    color: blanchedalmond;
    text-decoration: none;
    transition: all 0.7s ease 0s;
}
.navbar > li > a:hover {
    color: crimson;
}

.features {
    background-color: red;
    height: 100%;
    text-align: center;
    display: grid;
}

.boxs {
    list-style: none;
}

To enhance responsiveness, consider adding:

display: grid;
grid-template-columns: auto auto auto;
grid-template-rows: auto auto auto;
grid-column-gap: 100px;
And finally, remember to experiment with "max-width" and "flex-basis" attributes in your CSS code!

Answer №1

It is beneficial to utilize non-pixel values for padding, font-size, margins, etc when zooming in.

For instance, setting the font-size to the default page size (16px) and column spacing to 100px can lead to content overflowing the container since they do not resize accordingly.

Consider using "view units" (vw units) as demonstrated below. View units adjust dynamically based on screen size, making them more scalable than percentages. These units are calculated by dividing the screen into 100 wide by 100 tall segments, with support for partial units (e.g. 2.35vw), providing a high level of granularity.

body {
    padding: 0;
    margin: 0;
    width: 100%;
    height: 100%;
    font-family: Arial, Helvetica, sans-serif;
    box-sizing: border-box;
}



.main-container {
    background-color: brown;
    width: 100%;
    height: 100%;
    padding: 0;
    margin: 0;

}

nav {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    background-color: blueviolet;
}

.logo-img {
    margin-right: auto;
}

.navbar > li {
    display: inline-block;
    margin: 0px 10px;
    padding: 5px 10px;
    text-align: center;
}


.navbar > :nth-child(3){
    color: aquamarine;
    background-color: cornflowerblue; 
    border : 2px solid cornflowerblue;
    padding: 5px 5px;
    border-radius: 50px;
}

.navbar > li > a {
    color: blanchedalmond;
    text-decoration: none;
    transition: all 0.7s ease 0s;
}

.navbar > li > a:hover {
    color: crimson;
}

.features {
    background-color: red;
    height: 100%;
    text-align: center;
    display: grid;

}

.boxs {
    list-style: none;
    display: grid;
    grid-template-columns: auto auto auto;
    grid-template-rows: auto auto auto;
    grid-column-gap: 10vw;
    font-size:1.5vw;
}

.testimonials {
    background-color: yellow;
    height: 100%;
}

.pricing {
    background-color: green;
    height: 100%;

}
<main class="main-container">
        <nav class="navbar-container">
            <img src="logo.svg" class="logo-img">
            <ul class="navbar">
                <li class="select-items"><a href="#">Features</a></li>
                <li class="select-items"><a href="#">Testimonials</a></li>
                <li class="select-items"><a href="#">Pricing Table</a></li>
            </ul>
        </nav>
        <section class="features">
            <h1>The Benefits</h1>
            <p>Lorem ipsum dolor sit amet consectetur adipisicing elit.
                 Illum temporibus minima et ab aliquid</p>
            <ul class="boxs">
                <li>
                    <h2>GPS Tracking</h2>
                    <p>Lorem ipsum dolor sit amet consectetur adipisicing elit.
                    Illum temporibus minima et ab aliquid, enim veniam. Explicabo 
                    eius non ea magni itaque aspernatur distinctio voluptatem minima,
                    est, dolorem consectetur! Dolorem?</p>
                </li>
                <li>
                    <h2>Heartbeat Analysis</h2>
                    <p>Lorem ipsum dolor sit amet consectetur adipisicing elit.
                    Illum temporibus minima et ab aliquid, enim veniam. Explicabo 
                    eius non ea magni itaque aspernatur distinctio voluptatem minima,
                    est, dolorem consectetur! Dolorem?</p>
                </li>
                <li>
                    <h2>Security first</h2>
                    <p>Lorem ipsum dolor sit amet consectetur adipisicing elit.
                    Illum temporibus minima et ab aliquid, enim veniam. Explicabo 
                    eius non ea magni itaque aspernatur distinctio voluptatem minima,
                    est, dolorem consectetur! Dolorem?</p>
                </li>
                <li>
                    <h2>Innovative idea</h2>
                    <p>Lorem ipsum dolor sit amet consectetur adipisicing elit.
                    Illum temporibus minima et ab aliquid, enim veniam. Explicabo 
                    eius non ea magni itaque aspernatur distinctio voluptatem minima,
                    est, dolorem consectetur! Dolorem?</p>
                </li>
                <li>
                    <h2>Save your bills</h2>
                    <p>Lorem ipsum dolor sit amet consectetur adipisicing elit.
                    Illum temporibus minima et ab aliquid, enim veniam. Explicabo 
                    eius non ea magni itaque aspernatur distinctio voluptatem minima,
                    est, dolorem consectetur! Dolorem?</p>
                </li>
                <li>
                    <h2>Proven technology</h2>
                    <p>Lorem ipsum dolor sit amet consectetur adipisicing elit.
                    Illum temporibus minima et ab aliquid, enim veniam. Explicabo 
                    eius non ea magni itaque aspernatur distinctio voluptatem minima,
                    est, dolorem consectetur! Dolorem?</p>
                </li>
            </ul>
        </section>
        <section class="testimonials"></section>
        <section class="pricing"></section>
    </main>

For further information, please visit:

https://css-tricks.com/fun-viewport-units/

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

Text cannot be aligned

I recently encountered an issue where I center-aligned some text and positioned it using top:20%. Everything was working fine until I added a paragraph under it. At that point, the element moved back to its original position and the top:20% positioning did ...

Concealing the ellipsis in the will_paginate function of Rails

I'm currently utilizing will_paginate to manage a large number of values, but I am struggling to find a way to hide the "..." portion and the page numbers following it. Here is my current setup: https://i.stack.imgur.com/f2Tt8.jpg However, what I wou ...

Designing versatile buttons with HTML

When accessing the website on a phone, I have trouble seeing and tapping on these two buttons because they are too far apart. I would like to change it so that once a file is selected, the 'choose file' button will be replaced by the upload butto ...

"Creating Eye-Catching CSS Animation Effects with Dynamic Initial States

I am looking to understand how I can seamlessly transition from a hover-triggered animation to an exit-hover animation, regardless of where the hover animation is in progress. Currently, if I exit hover too quickly, the animation jumps back to its starting ...

Troubleshooting: Issues with Jquery's replaceWith function

I'm facing an issue with a table I have that includes a button in one of its columns. The button is supposed to toggle the class of the current row in the table and then replace itself once clicked. $(document).ready(function() { $(".checkOut"). ...

When resizing the browser window, this single horizontal page website does not re-center

I am in the process of creating my very first one-page horizontal website using jQuery and the scrollTo plugin. This site consists of 3 screens and initially starts in the center (displaying the middle screen). To achieve this, I decided to set the width o ...

Icon for local system displayed on browser tab

I am currently trying to set a Browser Tab icon for the local system, but it is not working. However, when using an HTTP static icon, it works perfectly. Can someone please help me understand what the issue might be? PAGE 1 : Icon Not Showing <link re ...

What steps do I need to take in order to transform this code into a MUI component complete with

Having some trouble converting my hero banner code to MUI in a React project. The styling is not coming out correctly. Here is the HTML code: <svg data-name="Layer 1" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1200 120 ...

Encountering issues with website optimization on Google Page Speed Insights and facing compatibility problems on a specific website I designed

I attempted to analyze the performance of my website using Google Page Speed Insights and encountered an error message. I have tried looking for a solution without success. Interestingly, when I tested other websites that I manage, everything worked just ...

Loading a specific number of rows in Datatables upon page loading: How to do it?

Recently, I came across a code snippet that uses AJAX to retrieve data from a specific URL and then displays the information in a table. However, I have a requirement to only load and display the first 10 rows of data during the initial page load process. ...

Determine the height using jQuery before adding the class

I've been grappling with jQuery to accurately calculate the height of an element and then apply a specific CSS class to adjust its height. The issue I'm facing is that jQuery seems to be executing these calculations out of order, which is causing ...

Tips for resolving HTML issues in AJAX Client Side-templates from WCF-webservice

I am facing an issue with my templates where the returned HTML is encoded by default, and despite my efforts, I can't seem to find a solution. My goal is to substitute NewLines (\u000a) with a simple <br />, but every attempt results in &a ...

The hyperlink function is not operational in Gmail attachments

Using an anchor tag to navigate to a specific section within the same page works perfectly when the HTML file is on my local machine. However, when I attach the file in Gmail and open the attachment, it doesn't work. Why is this happening? How can I m ...

Struggling with dynamically updating fields based on user input in real time

I have a goal to update a field based on the inputs of two other fields. Currently, all the fields are manual input. Below is the code I'm using to try and make the "passThru" field update in real-time as data is entered into the other fields. The ma ...

Step-by-step guide on displaying a tag image in HTML using html2canvas

html2canvas($('#header'), { allowTaint: true, onrendered: function (canvas) { var imgData = canvas.toDataURL("image/png"); console.log(imgData); } }); click here for an example ...

As I scroll, I hope the texts will stay fixed against the backdrop image

Is it possible to make the #home section fixed to the background while scrolling, including all the texts and buttons? I envision it like having texts embedded in an image. The text is located in the middle left of the page (let's keep this as default ...

How can I create an HTML select dropdown menu with a maximum height of 100% and a dynamic size?

The dropdown menu I created using an HTML select tag contains a total of 152 options. However, the large number of options causes some of them to be out of view on most monitors when the size is set to 152. I attempted to limit the number of displayed opti ...

"Adding dots" in a slideshow using HTML, CSS, and JS

I'm currently working on a slideshow that includes navigation dots at the bottom. Although the slideshow is functioning properly, I am encountering an issue where only one dot appears instead of the intended three in a row. Despite my research and att ...

Automatically adjusting jQuery script now functions on all hyperlinks for seamless resizing

I am attempting to create a rollover script that will resize my social network links when hovered over. The desired effect is for the 32px square icon to expand and display the trailing address. For example, when hovering over the Facebook link, it should ...

script code to limit selection of dates within a predefined range

I'm seeking assistance to limit my customers from selecting a date beyond 10 days in advance. Although I previously had a code that functioned properly when there were more than 10 days left in the current month, it is now ineffective. This is becaus ...