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

Angular 4 animation for smooth sliding down

Attempting to add animation to my webpage has presented a challenge: I have a content div on my page, along with a button that triggers the opening of another div above the content. My goal is to have this top div fade and slide into view while simultan ...

Where can I find the CSS classes for Material-UI?

I am new to Material UI and I want to explore its grid examples. However, when I tried coding the example provided below, it gave me an error saying that there was no CSS file found to load for these examples. Without including the className parameter, I ...

Title Bar: Excessive gap; inaccurate navigation to nearby link

I've been trying to align a horizontal navigation bar right below a banner and link directly to specific sections on the same page. No matter what I do, I can't seem to remove the white space between the banner image and the navigation bar. It ...

Activate the dropdown menu when ul element is in focus

I am working on creating a dropdown navigation using pure CSS. I want the dropdown menu to appear when clicking on the ul. The issue I am facing is that simple ul:focus > ul does not seem to work, even though there is an anchor within it. However, the : ...

The radio button is not providing the necessary notification

I currently have the following elements on my webpage: Table rows that contain radio buttons A link labeled "Issue" that triggers a popup with one submit button A submit button labeled "details" that also triggers a popup The issue I am facing is as fol ...

Customizing nested tables in your HTML email

When creating an HTML email template with nested tables for maximum email client support, the question arises about using inline styling. Should the style always be applied to the lowest level td, or is it possible to apply it to a parent table or td? For ...

When using Angular 8 with RxJs, triggering API calls on click events will automatically detach if the API server is offline

I have an Angular 8 application with a form containing a save button that triggers a call to a Spring Boot microservice using RxJs. I decided to test what would happen if the Rest API server were down. When the Rest API is running, clicking the button wor ...

Keeping an HTML field constantly refreshed with dynamic content from Django

Imagine having two input fields along with an HTML paragraph displaying a Django value. Field A: <input ...> Field B: <input ...> <p>{{ sum }}</p> The goal is to have the sum update in real time, meaning that once both numbers ...

Conceal the div on larger screens and display it on mobile devices

I have a fixed navigation bar at the top of my website. By default, it is always visible on all pages, but I want to hide it on desktop screens and display it only on mobile devices. Here is what I have implemented: @media (min-width: 992px) { #sp-he ...

Restricting choices once user selects an option (HTML)

Currently, I am faced with a dilemma regarding two sets of options for an HTML form. One set consists of various units (such as cm, in, ft.), while the other set includes different locations. The selection of a unit would restrict certain location option ...

Tips for maintaining horizontal alignment of menu links

I am frustrated with the vertical alignment of my menus (home, photos, paintings) on my website. I want them to be displayed horizontally instead. Can someone please assist me with this issue? <style> body{background:black} li a{ white-space: ...

Is there a way to prevent HTML Tidy from inserting newlines before closing tags?

Have you ever noticed how HTML Tidy always seems to add an extra newline before the closing tag? It's so frustrating! For instance: <p>Some text</p> ends up looking like this: <p>Some text </p> Is there a way to make Tidy k ...

Tips for adjusting the color of a pin without altering anything else

I have a Google Marker with a default design. By default, I can create the pin with letters inside it. However, I want to change the color of this pin. So, I attempted to use this icon: Unfortunately, the letters shifted and the size slightly changed. ...

Is the Pure CSS hide/show technique using radio buttons causing a challenge with parent and descendant elements?

Exploring a CSS Show/Hide functionality using radio buttons is my current challenge. The snippet below demonstrates how smoothly it works. .refusal, .acceptance { display: none; } input#refusal:checked~.refusal { display: block; } input#acceptanc ...

Guide to creating a dynamic illumination using CSS, HTML, and JS

Can you help me create a unique lighting effect for a specific section of my webpage? I'm curious about the techniques needed to achieve a similar effect as seen on another webpage. Is it feasible to create this effect using only CSS and HTML, or are ...

What is the best way to flip the direction of the text input for a Calculator?

I am currently working on creating a basic calculator from scratch using HTML, CSS, and JavaScript. I have been trying to figure out how to align the numbers to the right side of the input element. Can anyone provide me with guidance on how to achieve thi ...

Save user entries in a database array

I'm working on developing a platform for advertisements where users can create detailed profiles with images. To achieve this, I need to store the information in an array within a backend database for future retrieval. Below is an example of the backe ...

Leveraging the browser's built-in validation error messages in Angular for HTML forms

Is there a way to incorporate browser's native HTML validation error messages into Angular applications? https://i.sstatic.net/J0em4.png What I am looking for is the ability to leverage the built-in error messages when working with reactive forms li ...

determining the number of td elements in a row of a table located within an iframe

When I interact with a cell in a table within an iframe, I want to determine the number of cells in that row. If a cell is actually a span element, I would like to consider it as part of the cell count. The iframe may contain multiple tables without any s ...

Surprising CSS overflow error

Recently, I've encountered a CSS overflow issue while working on a responsive webpage. The problem seems to be stemming from the navigation menu. The declaration of "overflow-x: hidden" is specifically causing the trouble... Initially, I suspected i ...