Hide the overflow for images

Looking for a way to display 6 images divided into 2 rows and 3 columns on large screens, but switch to displaying only 4 images with one image per row on small screens? You can achieve this using CSS. Any ideas on how to implement it? Thank you.

Answer №1

Implement Bootstrap 4 visibility classes:

[class*="col-"] {
  margin-bottom: 15px;
}

.images img {
  width: 100% !important;
  height: auto;
}
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/4.1.0/css/bootstrap.min.css" rel="stylesheet" />
<div class="container images">
  <div class="row">
    <div class="col-sm-12 col-md-4"><img src="https://placeimg.com/640/480/any" alt=""></div>
    <div class="col-sm-12 col-md-4"><img src="https://placeimg.com/640/480/any" alt=""></div>
    <div class="col-sm-12 col-md-4"><img src="https://placeimg.com/640/480/any" alt=""></div>
    <div class="col-sm-12 col-md-4"><img src="https://placeimg.com/640/480/any" alt=""></div>
    <div class="col-sm-12 col-md-4 d-none d-md-block"><img src="https://placeimg.com/640/480/any" alt=""></div>
    <div class="col-sm-12 col-md-4 d-none d-md-block"><img src="https://placeimg.com/640/480/any" alt=""></div>
  </div>
</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

Trigger a function from a Bootstrap modal

Here is a preview of my HTML code : <form action="form2_action.php" method="post"> <table> <tr> <td>First Name </td> <td>:</td> <td><input type="text" id="f ...

Why is the reverse sticky navbar not visible after the position changes from fixed to static?

Scenario In the setup, I've implemented a reverse sticky navbar where it remains in position:fixed at the top. However, once the top of a specific div container touches the bottom of the navbar, I switch it to position:static using jQuery. Challenge ...

Tips for customizing the color of the current date in the angular-material datepicker

I've created a function in angular-material to disable dates two days from now, but I'm struggling to change the color of the current date if it's disabled. The issue is that when the current date is disabled, it displays in a very light blu ...

Show or hide a specific element based on whether a certain radio button is selected or deselected

After successfully displaying an element on radio button selection, I encountered the issue of the selected element remaining visible when another radio button in the group is chosen. What aspect am I overlooking? Regarding hiding elements with vanilla Ja ...

Scrolling Container Following Down the Page, Halts at Its Own Bottom (Similar to Twitter)

I am facing an issue and need some help. I am working on creating a three-column page layout where the middle section is for posts, the right section is for links and references (a bit long), and the left section is fixed. My question is: How can I preven ...

how to obtain the lineHeight property in UITextView

I am trying to calculate the line height in UITextView for my app. I have used the sizeWithFont:constrainedToSize:lineBreakMode: method, but it seems to give me the height of all lines in the textview. I heard about the Three20 library, but I am not sure h ...

Customized placement of form fields on an HTML grid determined by the user

My goal is to organize input elements on a grid based on user preferences. After researching, I stumbled upon CSS grids, which seem promising. I am considering creating a CSS grid with r rows and c columns, then using JavaScript to assign input elements t ...

When I test my jQuery scripts in jsfiddle, they run smoothly. However, they do not seem to work properly when I

My code is almost perfect, but the jQuery function is giving me trouble. It works fine in jsfiddle, but for some reason, it's not functioning in my HTML file. I don't believe extra characters are being added when copying from the HTML file. I hav ...

What are the steps to create a basic chrome extension that functions as a countdown clock?

I am a beginner in the world of coding and I am currently working on creating a chrome extension that serves as a timer. My goal is to include the timer within the HTML popup file, allowing users to customize the settings themselves. Do you have any advice ...

The execution of Ajax is not taking place

Hey, I'm facing an issue with AJAX in my project. It's working fine in other files, but for this specific instance where I call scripts/claim.php and pass an id parameter via GET, it's not functioning as expected. HTML <input type="hidd ...

How can I implement JQuery in JavaScript to enhance functionality on an HTML webpage?

I'm currently working on a website project and I'm running into some trouble with my jQuery library. I've tried implementing the code below, but it doesn't seem to be working. I'm using Notepad++ with Denwer local server. <scrip ...

Extracting JavaScript variable data to PHP using Ajax technology

I've been trying to save latitude and longitude values in PHP variables, but I'm having trouble. Here is the code I'm using. Can anyone please help me figure out why these values are not being stored in PHP variables: Code: <!DOCTYPE h ...

Hyperlinking Github.io Images

I'm facing an issue regarding image paths on github.io. It seems like the images from my github repository are not displaying properly (I made sure to check spelling and case sensitivity). I'm running out of ideas, so maybe you can help me spot m ...

Sending arrays from HTML table rows to a JavaScript function

When developing a dynamic table using Javascript, I am able to add rows programmatically with the following function: function addrow(tableid) { var tablename = document.getElementById(tableid); var rows = tablename.rows.length; if (rows < ...

Jquery spinner overlay for enhanced loading experience

Currently, I am incorporating jQuery/Ajax in my project and wanted to include a spinner when an ajax request is made. The specific scenario involves two tabs on the UI: Home and Activities. When the user clicks on the Activities tab, an ajax request is sen ...

A guide on incorporating Bootstrap 5 modal into an Angular project

I have added bootstrap 5 to my index.html file <link href="assets/css/bootstrap.min.css" rel="stylesheet" media="screen"> I attempted to implement the code from Bootstrap documentation on my Angular page, but it's not functioning correctly. ...

The iPhone header position switches when an HTML5 input type number is selected

I am currently working on a project that involves jQuery Mobile and PhoneGap. One issue I am encountering is when using the iPhone version, the header position changes when I click on an input type number. NOTE: When I focus on the input type number in my ...

What is the process for assigning a class to every button on a webpage?

For a recent project, I utilized input[type="button"] to add a style to all of the buttons. Although it functions properly on most browsers, Internet Explorer 6 does not recognize the styling. Is there a workaround for this issue? Perhaps creating a speci ...

Create an additional column in HTML using Bootstrap styling

I am currently working on a CRUD form (using PHPMyAdmin for the database), developed in HTML, JavaScript, and PHP. The queries are executed using jQuery. I am facing an issue with my code - whenever I add a new column to my table, the formatting gets messe ...

Scrolling vertically results in scrolling horizontally

As I build a frame and grid for my website, an issue arises whenever the page extends to display the vertical scrollbar, the horizontal one appears as well. I've experimented with various overflow-y settings like auto or hidden, but none of them seem ...