Looking to repair CSS for preventing DIVs from overlapping

My template features a main image with thumbnails below it, but each product may have a different number of thumbnails with varying aspect ratios.

To ensure that the thumbnails look appealing, I scaled them all using the following CSS:

#product-thumbnail {
    height: 100px;
}

#product-thumbnail a img {
    height: 100%;
}

All these thumbnails are contained within a 630px wide container. If there are multiple thumbnails, they spill over to a second row, overlapping my description text.

I attempted to use 'clear: both' on my description div, but unfortunately, it didn't work as expected.

Here is the link to my jsFiddle for reference: http://jsfiddle.net/7eY3M/1/

Any assistance would be greatly appreciated!

Answer №1

    #product-thumbnail {
        display: block;
    }

    #product-thumbnail a img {
        vertical-align: middle;
        height: 100px;
        margin: 5px;
        box-shadow: 10px 10px 20px #909090;
        -webkit-box-shadow: 10px 10px 20px #909090;
        -moz-box-shadow: 10px 10px 20px #909090;
    }

Adjust the height to 100px within the images themselves, not in the surrounding div.

Check out the updated fiddle here!

Answer №2


~UPDATE~

One effective method is to utilize individual

elements with a height of 100px inside another container div, each styled with float:left. This approach will maintain the images in a row while allowing them to wrap naturally, preventing overflow issues. Remember to include display: inline-block; within your
<div id="product-thumbnail">

Failure to do so can lead to awkward positioning of the description, unlike using either display: block or display: inline.
Css
#product-thumbnail {
display: inline-block;
min-height: 100px;
float:none;
}
.thumb
{height=100px;<br>float:left;}




    <code><div id="product-thumbnail">

<div class="thumb"> <img src=img1> </div>
<div class="thumb"> <img src=img2> </div>

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

What are the benefits of incorporating CSS into a CSS block rather than utilizing inline output with HtmlHelper in CakePHP?

Just a few days ago, I embarked on the journey of learning CakePHP through their blog tutorial. Now, I am diving into writing my own small project to gain hands-on experience with the framework. After going through their documentation, I discovered two ...

What is the best way to send the value from a textbox to this script?

My challenge is with this particular textbox: <input type="text" autocomplete="off" required="required" id="bar" name="bar" class="form-control" placeholder="Barcode"> Also, there's a button in the mix: <button type="button" style="float:r ...

Retrieving information from an API and incorporating it into JSX results in displaying text within the HTML element

I have retrieved data from an API with the following response: { "name": "family: woman, woman, girl, girl", "unicode": "1F469 200D 1F469 200D 1F467 200D 1F467", "html": "&#128 ...

Tips for adding a string variable to a JQuery HTML element attribute

Hi there, I've been working on a JQuery code to append data to a div element and it's been successful so far. Here is the code: $('#conversation').append('<div id="receiver"><p><b>' + username + ':< ...

Is it possible to adjust the width of the comment box on the Facebook "Like" button?

Is there a way to set the width of the comment box that appears after clicking the Facebook "Like" button? I know how to adjust the width of the button itself and related content, but can't find any options for the comment box: I've tried overri ...

Generating columns in Plotly Dash according to user input

I'm currently developing a selection menu that allows users to choose the number of experiments they wish to compare or view. Based on this input, I aim to dynamically adjust the number of columns displayed, with each column representing an experiment ...

What could be causing my CSS/Layout to alter once AJAX/JavaScript has been executed?

When the user clicks, an AJAX call is made to retrieve data from a third-party API. The frontend/layout renders correctly before this action; however, after the data is fetched and displayed in the frontend, the layout changes. Upon debugging multiple tim ...

The progress bar fails to update once it hits 100%

My circle progress bar is not resetting to start over when it reaches 100%. The code seems to work fine in my browser, but for some reason it's not working on JSFiddle. Here is the link: https://jsfiddle.net/BrsJsk/5e9hs69y/5/ window.onload = fu ...

Tips for preventing Uncaught SecurityError: Blocking a frame with origin in phonegap

I'm in the process of developing a phonegap application that serves as a miniature browser for a client's website. This app will allow the client's customers to access their favorite pages with ease. Once a user selects a favorite, it will b ...

Uniform Column Height Functionality Exclusive to Desktop Devices

I have a snippet of code in my Bootstrap 5 website that looks like this <div class="row mt-3"> <div class="col-md-6 mt-3 mt-md-0"> <a href="post/good-morning-status-shayari-68346" class="h-100&q ...

Ways to create a scrolling container with dynamic CSS transformations

Visit this website with a unique feature - a scrolling div on the left. The div scrolls along rhythmically as you navigate through the page, changing colors dynamically. The use of position:fixed is not the only method to achieve this effect. So, what oth ...

CSS - Is there a way to alter the arrangement of DIVs depending on the size of the screen?

My inquiry pertains to a CSS layout. I currently have 3 divs positioned in a horizontal line next to each other, as depicted below... div1 div2 div3 I am aiming for the divs to reorganize themselves as the screen size decreases. In one scenario, they sho ...

The simplest way to increase the size of a child element in order to generate a scrollable area

When working with HTML, it's important to consider how the size of a child div affects the parent div. If the child div is larger than its parent, scrollbars will appear on the parent div if the appropriate style rules are set. However, I'm inte ...

Combine table cells to improve readability on smaller screens

I currently have a setup designed for larger screens: <table> <thead> <tr> <th>title and image</th> <th>description</th> </tr> </thead> <tbody> ...

Utilizing blend modes to invert colors

I'm working on a code where I need to change the color of certain points when they overlap with a segment, and partially change their color when hovered over by a rectangle. I attempted to achieve this using mix-blend-mode but it didn't work as e ...

Building a personalized payment experience using Python Flask and Stripe Checkout

I'm attempting to set up a customized checkout integration with Stripe on my Flask web application and I've encountered some issues. After copying the code from the Stripe documentation (located at https://stripe.com/docs/checkout#integration-cu ...

Google Map not rendering correctly when dynamically implemented for the second time

When this specific HTML code is pasted into an .html document and opened directly in a web browser, it showcases the issue I am experiencing. <!DOCTYPE HTML> <html ng-app="myApp"> <head> <link href="https://netdna.bootstrapcdn.com/bo ...

Is it possible for the JavaScript DOM API to retrieve the exact casing of attribute and tag names?

Is it possible to retrieve the original casing of an attribute name or tag name from the source? The attribute name is in lowercase The tag name is in uppercase The local element name is in lowercase I am looking for a solution that doesn't require ...

Combining Django HTML Tags for Optimized Looping with Conditions

I am currently utilizing Django and I have a query regarding adjusting the tags below in order to halt the iteration of the for loop once a specific condition is satisfied. webpage.html <div> {% for person in crew.crew_set.all %} {% if person.job| ...

Tips for positioning text next to a hyperlink using HTML or CSS

Is there a way to align text next to a link without it being part of the link itself? For instance, text - link That's how I'd like it to appear ...