Prevent Grid Container from resizing when text is added

Currently, I am in the process of creating a Grid Layout for the Homescreen of my Website and so far everything is working fine. Six Images are positioned loosely on the screen and scaling properly. But whenever I attempt to add text in the container below one of the images, each image changes its size. Additionally, they all behave differently even when just a few letters are added.

Visit this link for reference

Take note of how the pictures react when text is added in the

<div class="hometext01">
. I cannot seem to figure out why they start resizing immediately and would like to learn how to prevent that from happening.

HTML:

<div class="homescreen2">
    <div class="homeimg01 hometransition"></div>
        <div class="hometext01">test test test</div>
    <div class="homeimg02 hometransition"></div>
    <div class="homeimg03 hometransition"></div>
    <div class="homeimg04 hometransition"></div>
    <div class="homeimg05 hometransition"></div>
    <div class="homeimg06 hometransition"></div>
</div>

CSS:

.homescreen2 {
    display: grid;
    grid-gap: 0px;
    width: 100%;
    height: 100vh;
    padding-top: 110px;
    background-color: rgba(250,250,250,1.00);
    grid-template-columns:auto auto auto auto 
auto auto auto auto                     
auto auto auto auto                             
auto auto auto auto                             
auto auto auto auto                             
auto auto auto auto                             
auto auto auto auto                             
auto auto auto;
    grid-template-rows:       
auto auto auto auto
auto auto auto auto
auto auto auto auto
auto auto auto auto
auto;
}

Answer №1

When setting the columns to auto, keep in mind that the width of the column will adjust based on the content within it. To ensure a more consistent layout, consider using 1fr instead. Furthermore, you can simplify the code by utilizing the repeat function.

In the .homescreen2 class, utilize

grid-template-columns: repeat(31, 1fr);

rather than

grid-template-columns:  auto auto auto auto 
                        auto auto auto auto 
                        auto auto auto auto
                        auto auto auto auto
                        auto auto auto auto
                        auto auto auto auto
                        auto auto auto auto
                        auto auto auto;

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

Implementing Bootstrap 3.1 to prioritize main content at the top on mobile devices

Below is the grid structure that I am working with <div class="row"> <div id="A" class="col-md-3"> <div class="alert alert-info">A</div> </div> <div id="B" class="col-md-6"> <div class=" ...

Dealing with a Bootstrap 4 fixed-top navbar issue: Uncovering the mystery behind the white space

I'm encountering an issue with the navbar that is causing a white space: see screenshot. Here is the HTML code I am using: <div class="header"> <div class="overlay"></div> <nav class="navbar fi ...

Custom 404 Page by Google

Could anyone provide information on the property #goog-fixurl for the custom 404 widget? I've searched but can't seem to find any documentation on it. I'm familiar with all the other property styles #goog-fixurl Any assistance would be grea ...

Creating images or PDFs from HTML with CSS filters: a guide

Looking for someone who has experience creating images or PDFs from HTML code. The HTML contains images with CSS filters such as sepia and grayscale. If you have worked on this type of project before, I would love to hear about your experience. <img cl ...

Challenges with navbars and Bootstrap

Just started using twitter-bootstrap and I'm trying to customize the navbar by removing borders and padding, adding a hover effect for links with a different background color, and setting margins of about 10px on the left and right. However, I'm ...

Styling a select drop-down menu with CSS to show a button in Chrome and Webkit browsers

On my HTML page, I have a basic drop down menu set up like this: <select name="menu" class="menu"> <option value="a">A</option> <option value="b">B</option> <option value="c">C</option> </select> ...

The width of a CSS border determines its height, not its width

When I try to use border-width: 100px; to set the horizontal width to 100px, it ends up setting the height to 100px instead. Any help would be greatly appreciated. .border-top-green { border-top: 1px solid #4C9962; border-width: 100px; padding-t ...

CSS problem with padding and width

Currently, I'm working on a conditional rendering issue where I want to give a div full width but due to padding applied to its parent, it's not expanding to the container's full width. Here is the snippet of the code: import Image from &qu ...

Leveraging bootstrap for generating a grid structure with image sizes that adjust dynamically

Just dipping my toes into the world of CSS, so please be kind ;). Here's a setup I have for a grid: <div class="row"> <div class="col-lg-2 col-sm-3 col-xs-4"> <a href="#" class="thumbnail"> <img src="http:// ...

Centering text vertically in a horizontal form row with Bootstrap 4

How can a div with text be centered vertically in a Bootstrap 4 Horizontal form? For example, instead of a form input have a plain text div like "Password goes here," you can use the following code snippet: <form> <div class="form-group row"&g ...

What are the best ways to create image animations on top of other images using CSS or JavaScript?

Imagine if the first image is in black and white, while the second one is colored. How can we make the black and white image change to color after a timeout period, with an animation similar to loading progress bars? Is this achievable using CSS or JavaScr ...

Can one customize the background color of a segment in a radar chart using Chart.js?

Could I customize the color of the sectors in my radar chart to resemble this specific image? https://i.stack.imgur.com/U8RAb.png Is it feasible to achieve this using Chart.js? Alternatively, are there other chart libraries that have this capability? It ...

What's the best way to activate multiple functions when the same key is pressed repeatedly?

I encountered a challenge while trying to set up different functions for the same key press event. Specifically, I wanted to call function1 when the space key was pressed once, function2 when it was pressed twice, and function3 when pressed thrice. Despit ...

Is it possible to use CSS and HTML to rotate a cube and expand its sides?

I am attempting to rotate the cube and expand its faces. I have experimented with the following code: .wrapper{ position: absolute; top: 50%; left: 50%; transform: translate(-50%,-50%); } .cube-wrap { width: 40px; height: 40px; ...

Personalized designing of each letter

Is there a way to style numbers without using something like <span></span>? I'm looking for a clean way to do this for each sign. Attached is an example showing a "flip clock" effect that I would like to achieve. I have come across plugi ...

The alignment of text in certain columns is not functioning properly in CSS tables

In my project, I am dealing with two columns. One column contains values for a variable, while the other column consists of rankings assigned to those values. The rankings column is working perfectly; it is aligned on the left side and occupies 70% of the ...

Difficulty in managing vertical overflow in a dynamically sized table using Bootstrap

I am facing an issue with the table-responsive class that is causing a scroll on the y-axis even though it is not specified in the CSS. Shown below is a screenshot of the problem, and I have also managed to replicate the bug: <div id="app"> <d ...

Softening the edges of a table

Could you assist me in rounding the corners of my table? I attempted using the basic border-radius, however, it only separated the border at the corners. Do you think this issue is due to my browser (Firefox) or could it be a bug? You can view my Jsfiddl ...

What would cause a flex-basis calculation to throw an error in SASS?

Today, I was working on a flex-grid generator in scss, which is something I do often. However, I encountered an unexpected error this time. I am using a 12-col-grid system and my approach should work fine with the code flex: 0 0 #{100 / 12 / $i}%;. There m ...

A technique for displaying and concealing a div element when an input field is

How can I hide one div and show another upon click action? The Existing Div <div class="container"> <div class="row"> <input class="abc" type="text" /> </div> </div> The Hidden Div to Show on Click <div class="contai ...