Sliding sideways with CSS thumbnail navigation

My goal is to create a horizontal scroll menu for a series of thumbnails. I have managed to make it scroll horizontally, but the issue I'm facing is that the thumbnails stack on top of each other and continue to scroll vertically within my div. What I want instead is to have all the thumbnails in one row that scrolls horizontally when there is overflow in the 'x' direction. Additionally, I would like the height of the div to be proportional to the width of the thumbnails. Currently, setting the height to auto results in the container expanding to accommodate all 50 images in multiple rows rather than just one row. Here's the code snippet:

HTML (.ejs file):

<div class="thumbnail-container">
   <ul class="thumbnail-list">

   <% for (var i = 0; i < listData['photos'].length; i++) { %>
      <li>
         <span><img class="thumbnail-image" src="http://www.realcove.net/<%=listData['photos'][i]%>"></span>
      </li>
   <% } %>
   </ul>
</div>

CSS:

.thumbnail-container {
    overflow-x:scroll;
    height: 75px;
    width:100%;
    padding: 0 15px;
}

.thumbnail-list {
    white-space:nowrap;
}

.thumbnail-image {
    display: block;
    padding:2px;
    max-width: 100px;
    height:auto;
}

I've done some research and I feel like I'm very close to achieving the desired result. However, something seems to be missing or incorrect. Any suggestions on how to fix this issue or any errors that need to be addressed? Your assistance would be greatly appreciated. Thank you.

Answer №1

Your list element still has a display property that causes the elements to stack vertically.

To change this, you can set it to display: inline-block;

Regarding your other question, adjusting the container height to auto will make it proportional to the thumbnail size. This will be effective once you have changed the display property to inline-block;

.thumbnail-list li {
   display: inline-block;
}

Check out this example on jsfiddle: https://jsfiddle.net/e99wfqku/1/

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

Adding CSS styles to a pre-existing table structured like a tree

Can a CSS style be applied to a pre-existing HTML table structured as a tree? For instance, in Firefox, the Bookmarks Library table is set up as a tree. Is it feasible to add a CSS style to one specific column without affecting the others? While using tr ...

Detecting the specific button that was selected with PHP

I am in the process of developing a website for a production company where, upon clicking on a director's name from the menu, all other menu items disappear and only the selected director's biography and work are displayed. My current challenge ...

Sending Emails Using Javascript & CSS via SMTP in a Contact Form

Currently fine-tuning a contact form and nearing completion. However, there seems to be a minor error preventing the form from submitting correctly. Expected behavior includes a pop-up confirmation box upon submission and successful message delivery. Yet, ...

Is the primary color modification in Bootstrap failing to take effect?

Currently, I am working on a react app and I have successfully integrated Bootstrap React. One of the tasks I wanted to accomplish was changing the primary color from the default blue to a different shade. To do this, I navigated to bootstrap/scss/variabl ...

I want to set a single background image for all slides in fullPage.js. How can I achieve this

I am attempting to replicate a similar effect as shown in this example: The demonstration above utilizes the fullPage.js plugin. You may have noticed how the background image remains consistent while navigating through different sections. I have searched ...

Error: The selector "button" cannot be used in its current form as it is not pure. Pure selectors must include at least one local class or ID

<button onClick={() => resetBoard()}> Reset Board </button> While trying to import an external CSS file as a module, I encountered a problem. The CSS file looks like this... button { background-color: ...

IE doesn't seem to support framesets, while Mozilla browsers handle them just fine

Can anyone help with this code that works in Mozilla but not in Internet Explorer? The situation is urgent. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Frameset//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd"> <html lang="en" xmlns= ...

What can I use instead of "display:none" in Javascript or Jquery?

A problem I encountered with my website involves a menu that toggles content visibility based on menu item clicks. The JQuery script responsible for this behavior is shown below: $(document).ready(function() { $("#bioLink").click(function(){ $ ...

Div automatically shifts to center position when other div elements vanish from view

I am new to jquery and currently working on a basic website. The site consists of three boxes, each of which, when clicked, causes the other two to fade out using the .fadeOut('slow'); method. However, there is an issue - all of the boxes are enc ...

Overlapping sliding toggles with jQuery on multiple elements

Just starting out with jQuery and I've come across a few examples of slideToggle but they are all overlapping. Here's the code I have so far: jQuery: <script src="jquery-1.9.1.js"> </script> <script> $ (document).ready(fun ...

How to completely color a div in CSS

<h:head> <title>Unique Title</title> <style> .top{ margin: 0; padding: 0; background-color: blue; height: 15px; width: max-content; } </style ...

The debate between background-image and background: Choosing the right

Experiencing a puzzling issue that seems to have a straightforward solution that I just can't see. I am trying to switch the background to a background-image, but for some reason, the image is not displaying. The code provided below does not show the ...

Activate the display by utilizing the getElementsByClassName method

In my design, I'd like to have the "Don't have an account?" line trigger the display of the .registrybox class when clicked. However, the script I've written doesn't seem to be working as intended. The script is meant to hide the .login ...

Is it possible for this solution to be compatible with IE7 and IE6?

Is there a way to enhance this solution for compatibility with IE6 and IE7? http://jsfiddle.net/kirkstrobeck/sDh7s/1/ Referenced from this discussion After some research, I have come up with a practical solution. I've converted it into a new func ...

Tips on deobfuscating Next.js HTML from online sources

I am faced with the task of reconstructing a website that I scraped from the internet using wget. It seems to be built on next js, based on the presence of the _next folder. Even though I have no experience with nextjs and do not understand its inner worki ...

Add two cells below a header with a colspan of one

I've been having trouble grouping the cells with the values { Lazy, Dog, Then, It } under a single header (with a colspan of 1) So far, I've attempted using div tags within the cells, creating multiple cells, and trying various combinations of w ...

Navigation menu with submenus containing buttons

I attempted to incorporate a dropdown into my existing navigation bar, but unfortunately, the dropdown content disappeared after adding the necessary code. I am now at a loss on how to troubleshoot this issue and make the dropdown function properly. Despit ...

Exploring Hover Effects in Reactjs and Material UI

I've been working with reactjs and material ui, but I'm having trouble changing the background color of selected items in various components, like in the SelectField. <SelectField floatingLabelText="Choose a sport" value={this.state.val ...

CSS: Create a form with two input fields where the left field is adjustable in width and the right field fills up

------------- -------------------------------------------------- | some unique text | | some more original content, varying length | ------------- -------------------------------------------------- |<---------------------- 100% width ------------------ ...

What is the best way to transmit a response from PHP to Ajax?

A JavaScript function is used here that utilizes the POST method to send form data to PHP. The PHP script then checks this data in a database to verify its authenticity. However, there seems to be confusion on how to convey the response from PHP back to Ja ...