Adjust the size of the image thumbnails according to the size of the window

Is there a way to use jquery/css to resize my gallery thumbnails relative to the screen size? I want the image gallery to fit all screen sizes.

For example, if the screen is 1280x800, the gallery should fit perfectly. However, if the screen is 1024x768, I still want the images to fit that screen as well.

Currently, my images are displayed like this:

<div class="imageWrapper"> 
<img src="1.jpg" id="1"> 
<img src="2.jpg" id="3"> 
</div>

I have up to 70 images with 10 images per row and 7 images per column. When resizing the window, I want the images to scale down accordingly based on the window size.

Answer №1

Could you share a code snippet with us so we can better assist you?

For example, consider the following code snippet:

<section>
  <p>Hello, World!</p>
</section>

A possible solution could be:

section p {
    font-size: 20px;
    color: blue;
    text-align: center;
}

However, if your elements have background images in CSS, the solution might look like this:

div.image {
    background-image: url('image.jpg');
    background-size: cover;
}

EDIT: To display multiple images in rows, you can create a grid layout with HTML like this:

<div class="grid-container">
    <img src="image1.jpg">
    <img src="image2.jpg">
    <img src="image3.jpg">
    <img src="image4.jpg">
    ....
</div>

And style it using CSS like this:

.grid-container {
    display: grid;
    grid-template-columns: repeat(4, 1fr); /* Assuming 4 columns */
    gap: 10px; /* Space between each image */
    justify-items: center;
    align-items: center;
}
.grid-container img {
    width: 100%;
    height: auto;
}

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

The technique for converting a JSON format date string into a date format

Currently, I am fetching data from a database using AJAX and displaying it in HTML text boxes for updating purposes. Below is the Web Method code that successfully retrieves the data: [WebMethod] public static List<Employee> getEmployee() { var ...

Attempting to understand how to effectively implement overflow: hidden

Here is a link to a demonstration showing how the text slides in and out from the left side of the container. I am currently working on resolving this issue. Do you think removing the display:table; property from the #right div would help??? <div clas ...

When hovering over the image, it enlarges and gradually becomes transparent, unveiling the hidden text beneath

I've been struggling to achieve the desired effect for quite some time now, putting in hours of effort without success. Essentially, I am aiming to create a div that showcases an image. When the mouse hovers over the image, it should zoom in and fade ...

Combine the points of individual letters in Scrabble using jQuery

Hello, I'm currently working on creating a Scrabble game. My goal is to assign a value to each letter and then calculate the sum of these values when the input box changes. After some research, I was able to find information on how to add numbers on ...

A textbox designed for use on both desktop and mobile browsers, utilizing jquery technology

In my Asp.net MVC project, I am facing an issue with textboxes that are meant to accept only text and certain keys like backspace and arrows. The code works perfectly in desktop browsers but returns the value 229 for event.keycode in mobile browsers. var ...

Processing JSON data through parsing in JavaScript

To fulfill the requirement, the data must be extracted via JSON and supplied to a chart. The data should be in the format of: var dataArray = [{data:[]},{data:[]}]; Below is the code to retrieve JSON data on the client-side: $.ajax({ type: "POST", ...

jQuery parseFloat causing loss of precision in price values

The code extracts a price value from a hidden input field named '#orginalAddon', then adds the cost of additional addons to this value and displays the total amount to the user. However, there seems to be an issue with truncation when the value i ...

I wonder why serialize() is not returning a response to me

As someone who is just starting to learn jQuery, I've been experimenting with the .serialize method in jQuery. Unfortunately, I haven't had much luck getting it to work properly. Despite connecting to the latest library (version 3.4.1) and checki ...

Experience seamless page transitions reminiscent of the fluid animations found on Medium.com

I'm currently investigating the animation used by Medium when you click on the bottom button to load the next article. If you want to see it in action, please visit a Medium article, scroll to the bottom, and click to navigate to the next article. W ...

How does altering the flex direction impact the height of the child elements?

I am currently attempting to create a media query using Flexbox in order to display an input element below another one instead of side by side. However, the issue I am facing is that when I set the flex-direction to column, the width of the input is not as ...

Mastering Space Between Row Items in Bootstrap 5 Grid: A Guide to Gutters

Hello, I am currently utilizing Bootstrap 5 and making use of the grid system. My layout is divided into 2 rows - one containing text and an image, and the other row consisting of two images. While everything looks fine on a PC, the mobile view displays t ...

Issue encountered while attempting to implement custom fonts through CSS

When attempting to implement a custom font on my website using the CSS file, I am having trouble getting it to display correctly. Instead of seeing the desired font, only the default font is showing up. Can someone please review the CSS code below and le ...

Below are the steps to handle incorrect input after receiving only one letter:

H-I This is my input .centered-name { width: 80%; margin: auto; } .group { width: 100%; overflow: hidden; position: relative; } .label { position: absolute; top: 40px; color: #666666; font: 400 26px Roboto; cursor: text; transit ...

Exploring Angular 5's capabilities with elevate-zoom usage

Check out this amazing Jquery Image Zoom Plugin! Having some trouble with the elevate-zoom jquery plugin in my angular 5 app. Getting this error message: ERROR TypeError: this.elevatezoomBig.nativeElement.elevateZoom is not a function https://i.ssta ...

What is the best way to use pattern matching to specifically match IDs while ensuring that the variable number aligns without needing to manually code every potential option?

I have recently acquainted myself with Jquery selectors and they are proving to be very useful. The issue I am facing currently is that all of my variable names follow similar patterns of starting and ending. The IDs are generated from elsewhere, and I am ...

Is there a way to determine if a kendoNumericTextBox widget already has a bound change event?

I'm working with a KendoNumericTextBox control and am attaching a 'change' event handler to it. After doing so, I'm trying to check if the change event handler has been successfully attached. However, when I use $._data(element,'ev ...

Calibrating height using CSS

Within my HTML document, I have the following structure: <div id="content"> <div id="wrapper"> <div id="steps"> <form id="formElem" name="formElem" action="" method="post"> <fieldset class ...

Page links in a JQuery clone are not operational

After dynamically generating page links at the top of my webpage, I attempted to clone them into a div located at the bottom. However, upon cloning, the copied page links fail to respond when clicked. Is this lack of functionality due to the fact that they ...

Is there a way to design a table that is responsive and automatically converts to a list when viewed on a mobile device

I am trying to design a responsive table showcasing artists' names. The goal is to have it look similar to this example: After finding and customizing code for the table, I encountered an issue when the table collapses on mobile view. The invisible e ...

Change justify-content-between to something else

After successfully fixing the issue with aligning the navbar brand in the middle of my navigation bar, I am now facing a new challenge. I want to add a button right before the right navigation toggle, but all my attempts have been unsuccessful so far. I&ap ...