The magic of CSS Flexbox properties

My HTML setup:

<div class="holder">
    <div class="box">
        <div class="unit" data-type="html" data-desc="I am HTML">
            <h2>HTML5</h2>
        </div>
    </div>
</div>

CSS code I'm using:

.holder {
    padding: 0 15px;
    max-width: 100%;
    height: 100vh;
}

.box {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    overflow: auto;
}

.unit {
    width:180px;
    height: 150px;
    background-color: #222;
    color: #fd5c8c;
    margin-bottom: 20px;
    border-radius: 5px;
    cursor: pointer;
    margin: 0;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    padding: 10px;
    border: 3px solid #0088CC;
    box-shadow: 0 0 9px #88bef5;
}

I'm trying to remove the gaps between the cards and add more, but struggling with how to accomplish this while using Flex properties.

Answer №1

Currently, you have set the width of both card and cards to 50%. This means they each occupy 25% of the available space. Since card is nested within cards, the width rule gets applied twice due to inheritance. To eliminate this issue, simply remove .cards from the width rule and update it to:

.card{
   Width:100%;

By doing so, the extra space vanishes.

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

To ensure maximum efficiency, it is crucial to iterate through each individual td element within a tr loop when extracting data from

I have successfully developed a code in JavaScript and AJAX to convert JSON data into an HTML table. The structure of the data is such that column 1 represents text, column 2 contains a link, and column 4 consists of links for images. Data: [ ["Produ ...

Employing jQuery to change the name of a div and subsequently selecting that specific div

Recently, I've been tackling a project that requires me to manipulate classes in jQuery. Specifically, I need to change the class of a particular div and then perform a specific action targeting that div with another jQuery function. The issue I' ...

Step-by-step guide on duplicating a div a set number of times

I am looking to replicate the entire div multiple times (e.g., on an A4 paper, top left corner, top right corner, bottom left corner, and bottom right corner). <script language="javascript" type='text/javascript'> function updateD ...

JavaScript allows you to create matrices from squares

Hey everyone, I'm facing an issue with creating matrices in HTML. I need to display a 5x5 matrix where each index is represented by a square. I tried using a span template for the box and then wrote a script to populate the matrices, but it's no ...

Preserve Original Styling Using Embedded Web Links

I'm currently in the process of creating internal page links on a website, but I'm facing a challenge in maintaining the original text formatting, which was a basic h4 heading. Despite various attempts, such as using a style with h4 settings and ...

Get the following table row using Selenium when a specific condition is met in the preceding row

Query I am currently working on scraping infoboxes related to French regions from Wikipedia. Specifically, I am interested in extracting the population data for each region. The population information for each region is displayed within the respective in ...

Angular dropdown menu not being populated

I need assistance in creating a menu that allows me to modify the "cell" attribute of an individual. The cells are specified as follows: Cells: [ { name: 'NE', id: 1 }, { name: 'NW', id: 2 }, { name: 'SE', id: 3 }, { name: & ...

Switching between different sections of a webpage

Seeking assistance with implementing a transition effect between sections on a single-page application. All sections are located on the same page, but only one section is displayed at a time. When an event occurs, the display property of the requested sect ...

What is the best way to add an external CSS file specifically for my custom Vue component?

Currently, I am working on a vue js component that I plan on uploading to npm. However, I have encountered an issue: Whenever I import a third-party CSS CDN into my component, it ends up applying the styles to the entire HTML instead of just my component ...

Initial two slides of the Bootstrap carousel appear clunky in full screen mode

After researching on various platforms, including Stack Overflow, I came across a similar question that I am facing now. Unfortunately, none of the solutions provided have worked for me so far. I apologize if this is repetitive, but I can't seem to fi ...

What is the best way to implement material theme colors into my Angular2 CSS?

Suppose I want to utilize the mat-primary color as a background for a div using a CSS/SASS class, how should I reference it? My initial thought was: @import '~@angular/material/prebuilt-themes/deeppurple-amber.css'; .my-class{ background-colo ...

What is the best way to hide the menu bar on a particular window using electron?

In my application, there is a menu that opens the document properties window when clicked. However, I am facing an issue where the application menu gets inherited by the document properties window itself, allowing you to open another document properties wi ...

Determine the present vertical measurement of the video

I am having trouble determining the actual height of a video element. Despite seeing in the developer tools that it is 384px, I am only able to retrieve a height of 342px. I attempted the following code snippet, but it only gives me the natural height, no ...

Position the caret after adding a new element in a content-editable div

I have a contenteditable div that contains various elements. My goal is to automatically create a new paragraph tag right after the element where the cursor is positioned when the user presses the enter key. Currently, I am able to insert the paragraph tag ...

Encountering a problem with the CSS locator select-react

I'm encountering an issue with a CSS locator. The parent has a unique label, which allows me to target the specific child element that I need. @FindBy(css = "[data-qa='select-Seller'] .select__value-container") Webelement seller; public Web ...

What is the process for using npm in conjunction with index.js and index.html?

Is it feasible to launch an application using npm without incorporating express? I have a simple setup with just one script file and one html file. Many resources mention adding node.js alongside express, but I am looking for an alternative method. My des ...

Is there a way to align a single button to the right in a flex column using Material UI?

After diving into Material UI and flex, I've spent some time poring over the documentation but I'm still struggling to figure out how to align only the <CancelIcon /> in a <Drawer /> to the right. I know that to prevent the <Drawer ...

Tips on keeping the cursor constant in CSS margins

Currently, I have a div that has a width of 160px and a height of 80px. Strangely enough, the div also has a margin-left of 540px. Additionally, in my CSS, I've specified cursor:pointer. The issue arises when I move my cursor to the left of the div, ...

The image persists between two floating elements, unable to be cleared

I have been trying to replicate the tutorial provided by this individual here. I timestamped it- and noticed that there is a text block that floats to the side. However, when I make one float left and the other float right, the image div continues to go in ...

What causes a slow disappearance of both the form element and its child elements when the visibility attribute is set to hidden on the

Have you ever noticed that the child elements of an element form hide slowly when using visibility:hidden, but hide quickly when using display:none? This slow hiding can negatively impact user experience. I tried to find information on this issue, but eve ...