Ways to adjust column size in CSS

I am currently working on an e-commerce website where all the products are displayed on the same page in "cols". Unfortunately, I am facing issues with fixing the column width and height using CSS.

<div class="container">
  <div class="row">
    <!-- BEGIN PRODUCTS -->
    <div
      class="col-md-3 col-sm-6 col-equal"
      *ngFor="let p of (titres | sort: titreSort)"
    >
      <span class="thumbnail">
        <img src="{{ p.URL_couv }}" alt="{{ p.id }}" />
        <h4>
          <label style="display: block; width: 600px;"
            >{{ p.titre }} n° {{ p.numero }}</label
          >
        </h4>

        <p></p>
        <hr class="line" />
        <div class="row">
          <div class="col-md-6 col-sm-6">
            <p class="price"></p>
          </div>
          <div class="col-md-6 col-sm-6"></div>
        </div>
      </span>
    </div>
  </div>
</div>

This is the current code I have implemented for displaying the products, my challenge lies in formatting them properly.

Here is a preview of how the products are being showcased:

https://i.sstatic.net/12k2K.png

Additionally, this is the CSS code I am utilizing:

   
.side-body {
  margin-left: 310px;
}
   
.right {
  float: right;
  border-bottom: 2px solid #4b8e4b;
}

.thumbnail {
  -webkit-transition: all 0.5s;
  transition: all 0.5s;
}
.thumbnail:hover {
  opacity: 1;
  box-shadow: 0px 0px 10px #41d834;
}
.line {
  margin-bottom: 5px;
}

@media (max-width: 768px) {
  .col-equal {
    margin: auto;
    display: flex;
    display: -webkit-flex;
    flex-wrap: wrap;
  }
}

If anyone could provide assistance or guidance on resolving this issue, I would greatly appreciate it. Thank you!

Answer №1

To ensure consistency in the height of all product descriptions, consider setting a min-height for the h4 element.

Answer №2

To fix the issue, consider adding a minimum height to the text block located beneath the image (description). This adjustment should help resolve your problem.

Answer №3

It appears that you are placing everything inside the tag, so in order to fix this issue, you will need to adjust the span tag to be a block or inline-block element.

Try using the following code:

.thumbnail{
    display: inline-block;
    width: your-width-value;
    height: your-height-value;
}

Answer №4

One way to achieve equal height on all columns in a row in Bootstrap is by using the class .row-eq-height. However, it's important to note that this feature is not supported in Internet Explorer.

<div class="container">
  <div class="row row-eq-height">

An alternative solution to address this issue is to apply flex-wrap: wrap; to the row element.

For more information, check out:

Answer №5

It seems to me that you are not utilizing Bootstrap V4, but rather V3.

Bootstrap V3 employs float: left, whereas Bootstrap V4 utilizes display: flex

example.com/code123 showcases Bootstrap V3 (with the issue)
example.com/code456 demonstrates Bootstrap V4 (without the issue)

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

Retrieve the personalized data-* attributes from a specific item within an array

I'm struggling to find the correct syntax for accessing custom data-* attributes for list elements within an unordered list that has been sorted and converted into an array using the following code: $("#gridlist").sortable("toArray"); The list eleme ...

Eliminate extra space beside the dark column on the right side in Bootstrap 4

For some time now, I've been struggling with an issue related to the left sidebar. When the sidebar is absent, the white space on the right disappears. I've tried various suggestions from others but none seem to solve the problem. I'm unsure ...

Transform [object HTMLDocument] to a String

Could someone guide me in converting the newHTMLDocument object into a full string including the doctype and html tag? let newHTMLDocument = document.implementation.createHTMLDocument(); let html = `<!DOCTYPE html> <html> <head> ...

AngularJS radio buttons are unable to be selected in a simplistic manner

I have implemented a dynamic list display using HTML radio buttons. Here is the code snippet: <html> <head> <script src="angular-v1.5.5.js"></script> </head> <body> <div ng-app="myApp" ng-controller=" ...

How can I position a Button at the center of my Grid item using Material UI?

In my React 16.13.0 application, I am utilizing Material UI's Grid and trying to center the content of a button in the middle of a row. Here is what I have tried: center: { alignItems: "center", width: "100%", }, halfRow: { width: "5 ...

Troubleshooting problems with jqplot pie charts

Currently, I am utilizing jqplot to create pie charts. Despite following the example code provided in the jqplot documentation, I am encountering errors such as "e.jqplot is undefined." Below is a snippet of my code: <script src="jquery-2.0.3.js"> ...

Why do identical elements show different scrollHeights when overflowed and how can this discrepancy be resolved?

I am using a plugin that generates a <p> element and continuously fills it with the content from a <textarea>. This plugin positions the <p> directly below the <textarea>, and styles them so that they appear identical in terms of th ...

Border becomes dashed when dragging and dropping

I am working on enabling drag and drop functionality for users. When an item is lifted from its original position, a gray dashed box should appear in its place. As the item is moved closer to another spot, the containers adjust to create a target area (gra ...

Choosing all components except for one and its descendants

I am searching for a method to choose all elements except for one specific element and its descendant, which may contain various levels of children/grandchildren or more. What I'm trying to accomplish is something like... $("*").not(".foo, .foo *").b ...

HTML - Align 3 tables horizontally with text below

I have successfully floated 3 tables next to each other using <table style="float:left;">. However, I am facing an issue where some text is being wrapped to the right side of the right-most table instead of being left-justified at the very ...

Adjust the header image as you scroll

Currently, I have a static image in the header of the page. I'm looking to have the image change to a different one when half the page has been scrolled. Do I need to utilize JavaScript for this functionality or is it achievable with CSS alone? bo ...

How to modify an array in an HTML document using BeautifulSoup

Running a Python script, I am trying to access a local HTML file containing a JavaScript array inside a script tag that needs updating. Here is the test code snippet: from bs4 import BeautifulSoup html = ''' <script> var myArray ...

Integration of a QR code scanner on a WordPress website page

I'm in the process of setting up a QR code scanner on my Wordpress site or within a popup. The goal is for users to be able to scan a QR code when they visit the page/popup link. Specifically, the QR code will represent a WooCommerce product URL, and ...

Flexbox that adjusts to any browser height, ensuring full responsiveness

I am exploring the world of flexbox with the goal of creating a responsive layout consisting of 3 items that adjust seamlessly to different devices such as smartphones, tablets, and desktop computers. The layout should stack the items on top of each other ...

Custom control experiencing issues with vertical alignment

I am currently working on creating a basic filter bar that includes a custom control element. My intention is to align the element vertically, but so far, I have been unsuccessful. Below is the code for the filter bar: <div class="bg-light p-3 card"&g ...

What is the best way to organize angularjs controllers and directives within one another?

When I structure my controllers like this: <body ng-app="app" ng-controller="ctrl"> <div ng-controller="app-get"> <app-get></app-get> </div> <div ng-controller="app-post"> <app-post">& ...

Elements are failing to respond to the padding and margin adjustments in my CSS styling

I've been experimenting with creating a visually appealing div that serves as the centerpiece of a website. Imagine it resembling a standard "news" link. The width set at 80%, an image aligned to the left with a border, a headline detailing the lates ...

`Center the image on top of the text`

Currently, I am working with Bootstrap 4 to create a component that includes two tiles. Each tile has an icon image on the left side and a hyperlink on the right side. On desktop view, the tiles should be displayed horizontally and vertically centered. How ...

Find the ID of the displayed div using jQuery

Here is the snippet of code I am working with: <div class="sequence-container"> <div id="1"></div> <div id="2"></div> <div id="3"></div> </div> Along with my jQuery script: $(window).load(function() ...

What is the reason behind Flask's choice to return <embed> files for download rather than simply displaying them

When I try to render a template using Flask that includes images, the files are being downloaded instead of displayed. For example, <embed src="static/yes.svg" type="image/svg+xml"> If I place this code inside test.html and view it in Google Chrom ...