Responsive image resizing with Bootstrap across various devices

In my search for answers, I have come across a few similar questions that don't quite address what I'm looking for.

Currently in the process of creating a portfolio website utilizing bootstrap 3, I aim to display three images across on small/medium/large screens and only two images across on extra-small screens within a div box.

The HTML structure for the images is contained within a div as shown below:

<div class="row" id="artpieces">
    <div class="col-md-12 col-xs-12">
        CODE FOR THE IMAGES
    </div>
</div>

Thus far, I've been able to achieve my desired layout of three images by using the following CSS:

#artpieces .col-md-12 img {
    width: 33%;
}

My attempts at adjusting the width for extra-small screens with the code below have not been successful:

#artpieces .col-xs-12 img {
    width : 49.5%;
}

Despite testing the percentages individually, they do not produce the desired outcome when combined. I suspect there may be a simple mistake that eludes me. As a novice in web development focusing on learning and practicing HTML and CSS, this issue presents the first significant challenge I've encountered.

Answer №1

Have you thought about organizing each image within a div using the classes col-md-12 col-xs-12?

Here's how it can be done in HTML:

<div class="container">
   <div class="row" id="artpieces">
      <div class="col-md-12 col-xs-12">
         <div class="col-md-4 col-xs-6">
            <img src="//placehold.it/300x350" class="img-responsive">
         </div>
         <div class="col-md-4 col-xs-6">
            <img src="//placehold.it/300x350" class="img-responsive">
         </div>
         <div class="col-md-4 col-xs-6">
            <img src="//placehold.it/300x350" class="img-responsive">
         </div>
         <div class="col-md-4 col-xs-6">
            <img src="//placehold.it/300x350" class="img-responsive">
         </div>
         <div class="col-md-4 col-xs-6">
            <img src="//placehold.it/300x350" class="img-responsive">
         </div>
         <div class="col-md-4 col-xs-6">
            <img src="//placehold.it/300x350" class="img-responsive">
         </div>
      </div>
   </div>
</div>

Check out the Live Demo: http://www.bootply.com/iy3Js8LV5X

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

HTML anchor tag failing to redirect to specified link

I need to populate the URI property from an API result into an HTML format. I attempted to achieve this by calling a function and running a loop 3 times in order to display 3 links with the URI property of each object. However, the code is not functioning ...

Struggling to display blob URL on "pdf-viewer" component with "ng2-pdf-viewer" in Angular version 10

I am facing an issue with an API that returns uploaded files as blobs. When trying to bind the src with a blob URL, nothing is shown. However, if I bind it with a direct URL, the PDF file is displayed successfully. Below is my code snippet. My TypeScript ...

The navigation tabs in Bootstrap are not functioning properly and are failing to show the corresponding content. Is anyone else facing this issue with Electron.js

I'm having trouble understanding why The tabs aren't changing when clicked The tabs aren't showing any content I'm working with electron and bootstrap, so I'd really appreciate any recommendations or solutions. I've looked ...

Tips for removing borders around a textbox with a background image: When incorporating a background image into a

After removing the default borders on a textbox using outline:none;, I noticed that adding a background image caused the border to reappear, and I couldn't get rid of it! How can I solve this issue? Here is the code for the textbox: <input type = ...

How can you easily center content vertically on a web page?

There has been plenty of back-and-forth regarding this issue, with proposed solutions ranging from pure CSS to pure HTML. Some can get quite complex, involving deeply nested divs and intricate CSS rules. I'm looking for a simple and uncomplicated answ ...

Django and facial hair (relying on laravel's index)

Previously, I developed some Laravel sites using technologies like SASS, jQuery, and Angular. Now, I am attempting to utilize these sites in Django, but I have encountered errors right from the start. 2 <html lang="PL"> 3 <head> 4 &l ...

Learn how to create a responsive flickr embedded video with Bootstrap!

I'm struggling to make the embedded video responsive. I attempted the solution mentioned in a Stack Overflow post but it didn't work for me. The video's width remains the same and doesn't scale down properly, appearing out of bounds on ...

Troubleshooting: Instagram API JavaScript Example Showing Errors

I'm currently working on integrating a photo feed from my Instagram account by following this tutorial: Below is the snippet of my HTML code with the addition of instafeed.min.js: <!DOCTYPE <!DOCTYPE html> <html> <head> < ...

The integration of Angular Reactive Form with Bootstrap is causing issues with custom validation not functioning properly during animation

After creating a Reactive Form in Angular 16 and adding Bootstrap validation to it, I encountered an issue where normal built-in validators work fine but custom validators do not reflect properly. Even though the error is added to the errors array, Bootstr ...

Handling input and datalist events

Is there a way to add event handling for when the selection is changed or the value is edited in a similar snippet like this? <input type="text" name="product" list="productName"/> <datalist id="productName"> <option value="Pen">Pen& ...

Using Python in Django to seamlessly add products to the shopping cart

Seeking guidance in creating a simple function that can capture the product ID and insert it into the user's shopping cart upon clicking the "add to cart" button. I have already set up the shopping cart table and the product table but am struggling to ...

tips on toggling div visibility based on data filtering

<script> function toggleContent(str) { if(str == 'recent' || str == 'old' && !($(".main_content").is(':visible'))) { $(".main_content").show(); } else if( str == 'newComment') { ...

Incorporating custom markers into Google Map API V3 by rounding and resizing photos

Is there a way to create a custom map marker for Google Maps by combining two images, marker_bg and marker_pic? I want the marker_bg to be a marker with empty space inside that will be filled by marker_pic. How can I round the picture and set it into the ...

Troubleshooting number positioning problems on Joomla website across different browsers

Recently, I encountered some issues on a Joomla website that I constructed using Joomla 3.5.1. I have utilized CSS to ensure the responsiveness of the site, which is functioning perfectly. The main issue arises with the header of the site displaying diffe ...

Utilize web scraping with Python 3 to extract data from the form

Currently, I am working on a project that involves web scraping. However, I am encountering difficulties when trying to extract information from an Iframe form, specifically the name, position, and company fields. Below is the code snippet that I have bee ...

Struggling to make justifyContent function properly when using flexbox in conjunction with material ui

I need assistance with returning JSX to the title prop of a material-ui card component. My goal is to have two boxes displayed with space between them, one on the left side and one on the right side of the header. Using flex box, I am able to display the ...

Tips for aligning text to the left within a Bootstrap accordion

I am in the process of developing a static website utilizing the W3schools "Company" theme. The complete code for this website, including CSS, is provided below: <!DOCTYPE html> <html lang="en"> <head> <!-- Theme Made By www.w3schoo ...

Optimal method for showcasing a logo bigger than the navigation bar

Seeking Advice: I am trying to incorporate a 100px by 100px logo on the left side of my navigation bar, which is only 50px in height. What changes can I make to the HTML and CSS structure for this design? My current setup includes: <div id="h ...

Disable a button during an AJAX request

Whenever a button is clicked, the record is saved to the database without refreshing the page using AJAX. I have implemented the AJAX code successfully. Now I need guidance on how to manage the state of the Submit button - enabling/disabling it dynamicall ...

What is the best approach to reverse the selection of <li> elements by utilizing :not() and :contains

I am looking to implement a live search feature using jQuery. Below is the code snippet I have written: $("#searchInput").on("keyup", function () { var searchTerm = $("#searchInput").val(); $('li:contains("' + searchTerm + ' ...