Optimizing Responsive Grid Layout by Including Rows and Eliminating Spaces

My attempt at creating a responsive grid layout has hit a snag. I currently have a 4x5 grid, but when trying to add more rows it goes awry. I've successfully implemented spinning squares in a 4x2 grid that I now want to expand to a 4x5 grid. However, achieving the desired layout with the divs and eliminating the gap between them has proven challenging. I aim for the squares to touch on all sides.

If anyone could assist in rectifying this issue and help transform my 4x2 grid into a 4x5 grid, I would sincerely appreciate it. Below is the code I'm working with.

CSS

.trigger {
  width: 64%;
  height: 64%;
  background-color: white; 
}

.hover-img, .hover-img.hover_effect  {
  background-color: white;
  position: relative;
  width: 200px;
  height: 200px;
  -webkit-transition: all 1s ease-in-out;
  -moz-transition: all 1s ease-in-out;
  -ms-transition: all 1s ease-in-out;
  -o-transition: all 1s ease-in-out;
  transition: all 1s ease-in-out;
  -webkit-transform: rotateY(180deg);
  transform: rotateY(180deg);
  -webkit-transform-style: preserve-3d;
  text-align: center;
  font-size: 0;
  -webkit-user-select: none;
  -webkit-touch-callout: none; 
  border-style: solid;
  border-width: 1px;
  border-color: #4595ff;
}

.trigger:hover > .hover-img {
  -webkit-transform: rotateY(360deg);
  -moz-transform: rotateY(360deg);
  -ms-transform: rotateY(360deg);
  -o-transform: rotateY(360deg);
  transform: rotateY(360deg);
  font-size: 14px;
  color: white;
}

.img1 {
  background-size: 100% 100%;
  background-repeat: no-repeat; 
}

.img1:hover{
  background-size: 100% 100%;
  background-repeat: no-repeat;
}
// Repeat pattern for img2, img3, img4, img5, img6

#container {
  width: 100%;
  display: flex;
  justify-content: space-around;
  flex-wrap: nowrap;
}

.column {
  float: left;
  width: auto;
  font-size: 12px;
}

HTML

<div id="container">
<div class="column">
<div class="trigger">
  <div tabindex="0" class="maincontent hover-img img1"></div>
</div>
<div class="trigger">
  <div tabindex="0" class="maincontent hover-img img2"></div>
</div>
</div>

// Repeated content from here for img3, img4, img5, img6...

</div>

Answer №1

If you take out the justify-content: space-around property from the #container in your CSS, it will eliminate the extra spacing, depending on your design goals.

#container {
    display: flex;
    flex-wrap: nowrap;
    justify-content: space-around;
    width: 100%;
}

For more information on this topic, you can refer to: http://css-tricks.com/snippets/css/a-guide-to-flexbox/

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

Prevent sibling divs from being affected by onClick events in React

Currently, I am facing an issue with changing the className of a specific div element when clicked. Whenever I click on one div, the classNames of all the div elements change. This problem arose from converting a vanilla JS concept into a React component. ...

Changes made to index.php are not reflecting on the WordPress website

Currently making changes to my WordPress theme and just included a new div with the class "sidebar." However, I'm encountering an issue where it's not updating on the homepage of the website. Strangely enough, the stylesheet does seem to be updat ...

Incorporate a Background Using PHP

There is a form on my website that includes a drop-down menu like this: <select name="status" class="form-control" style="width:100px; float:left;"> <option value="0" <?php if($status == 0)echo 'selected="selected"';?>& ...

Changing icons in a collapsed menu in Bootstrap 4

I have been working with Bootstrap 4 alpha 6 version and I am facing an issue with multiple collapse blocks on my page. I want to change the icon when a user opens or closes a block, so I tried using classes but it didn't work. Can you help me figure ...

What could be causing SimpLESS to throw a syntax error when encountering a forward-slash symbol in the background shorthand?

Can anyone explain why this specific line (line:2) is causing a syntax error on the SimpLESS compiler? When compiling in-browser using CDNs, there are no issues. However, the same code doesn't seem to work correctly on an iPad for some unknown reasons ...

Navigating through a Collection of Pictures using Mouse Movement and Left-click Button

Trying to create a customized PACS viewer for scrolling through a series of CT head images. However, encountering an issue with scrolling through all 59 images. Currently, able to scroll from the first to the 59th image, but struggling to loop back to the ...

What is the process for adding a gradient color to a button placed on a textbox

I am looking to create a textbox and textarea that include gradient effects similar to the image above. I have managed to implement it for a button. However, I'm having difficulty applying it to a textarea element. ...

Is there a method for displaying a gif with an alpha channel for transparency effects?

Is it possible to make the black color in a realistic gif animation transparent using CSS? The snow is white and everything else is black, but I want to overlay it on my header image with the snow falling realistically. I've seen animations of falling ...

Quantify the Proportion of Affirmative/Negative Responses and

I am attempting to calculate the percentage of "Yes" or "No" responses in an HTML table based on user input for each month's questions. Then, I want to display the average percentage in the "average" column for each month. For example, if the user sel ...

How can CSS be used to toggle the visibility of a div using an anchor object?

Is it possible to use a link that points to an anchor in the same document to control the visibility of divs within that document? This would allow me to display different content by simply changing the URL. Can this be achieved using CSS? For example: ...

Sliced Text Transformation

Recently, I inquired about a pesky text effect that was bothering me. Thanks to the assistance of fellow users, I discovered that the culprit behind the effect was the background color's edge. Eliminating this problem should be simple, but even with ...

Is it possible to reuse variables declared in a Javascript function within the same function?

string empCode = ds.Tables[0].Rows[i]["EMP_CODE"].ToString(); string empName = ds.Tables[0].Rows[i]["EMP_NAME"].ToString(); string gradeCode = ds.Tables[0].Rows[i]["GRADE_CODE"].ToString(); tr = new TableRow(); td = new Ta ...

HTML and SCSS: The slideout menu does not impact the content block until reaching a specific threshold

Note: Please note that this issue is specific to the desktop version with a minimum width of 64em. Codepen demo: Check it out here The Challenge Ahead The goal here is to ensure that the purple side menu does not impact the position or width of the ma ...

Using CSS, I have rearranged the content of a single row (tr) in an HTML table into two separate rows

I am currently facing a challenge with rearranging my table due to width constraints. My goal is to apply Jquery functions to the table in order to extract all parameters related to a product, but I want to avoid having nested tr elements or splitting para ...

What does the term "the selected font size" mean when defined in em units?

Exploring the query raised in this post: Why em instead of px?, the top voted response sheds light on the nature of em: The unit 'em' is not fixed but rather relative to the current font size. It varies according to the user's chosen font p ...

Constructing a horizontal slider using vertically floating divs

Struggling to create a basic horizontal image slider using overflow:hidden and floating divs. Despite efforts, the divs keep stacking vertically instead of horizontally. Numerous online examples have been attempted without success. HTML: <div id="slid ...

Establishing a connection from PHP to an SQL server in HTML

I have an HTML form that I need to use to filter the data in a SQL file. I am having trouble connecting to a local MySQL server and cannot seem to get into the table() function. This is the code I am using: <form id="form_id" action="food_values.php" ...

What is the best way to create a more compact Select component in React?

Working on React's Select component has been quite the challenge for me. I'm in the process of creating a simple dropdown button, also known as a ComboBox, similar to what can be seen on GitHub Insights: https://i.stack.imgur.com/J9Bcd.png Belo ...

Tips for utilizing asp:image in the code-behind

I'm having trouble with rendering an asp:image in my code behind. Let me explain my approach: In the Default.aspx file, I simply have one label element. In the code behind, I create a string variable and populate it, then assign this value to the labe ...

Tips for customizing the navigable page sidebar in Shiny with bslib

I am attempting to redesign my Shiny app page by incorporating bslib styles. I would like to achieve a sidebar layout similar to the one shown in Bootstrap's sidebar example, but I am unsure how to replicate it using shiny and bslib. Inquiry : How ca ...