Images that shrink in an inline block format

I'm having trouble making my in-line blocks shrink instead of wrapping. The layout of the images is currently like this:

AAA BBB

CCCCCC

As the window narrows to the width of C, I want all the images to shrink together. Right now, what is happening is that C shrinks and B wraps under A. If I apply whitespace:nowrap to the parent DIV, A and B do not wrap but they also do not shrink. Here's the code I have so far:

<div id="container">
<div class="small_pic"><img a></div>
<div class="small_pic"><img b></div>
<div class="large_pic"><img c></div>
</div>

#container {
margin-left:auto;
margin-right:auto;
width: 486px;
max-width:100%;
}
.small_pic {
width:220px;
max-width:100%;
display:inline-block;
height:auto;
}
.large_pic {
width:480px;
max-width:100%;
display:inline-block;
height:auto;
}

Thank you!

Answer №1

Consider using relative widths for the .small_pic class instead of absolute values. Adjusting from 220px to 45% should provide a more flexible and responsive design.

Answer №2

Upon reviewing your code, I noticed a missed detail regarding the width of elements, which should be defined in em's or %'s rather than px's. Just wanted to let you know that I was playing around with your code.

<div id="container">
<div class="small_pic">
  <img src="My_Bad_by_PhunkyVenom.jpg" class="firstImg">
  <img src="My_Bad_by_PhunkyVenom.jpg" class="secondImg">
</div>
<div class="large_pic"><img src="My_Bad_by_PhunkyVenom.jpg"></div>
</div>


#container {
margin-left:auto;
margin-right:auto;
width: 50%;
/*max-width:100%;
*/}
.small_pic {
/*width:220px;*/        // Instead of pixels
max-width:100%;
display:inline-block;
height:auto;
clear:both;
}
.firstImg,.secondImg{width:50%;float:left;}
.large_pic img{
/*width:480px;*/        // Using pixels.
width:100%;
display:inline-block;
min-height:100px;
height: 30%;
}

You can use em's (e.g., 300px ~ 18.75px). Avoid white-space and utilize float-clear. Hopefully, this explanation clarifies things for you.

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 gradual disappearance and reappearance of a table row

I am struggling with making a row fade out when a specific select value is chosen (such as "termination"), and fade in when any other option is selected. The code works perfectly fine when the div ID is placed outside the table, but once I encapsulate it w ...

Angular background image not displayed

After searching extensively, I came across many examples that didn't work for me. I'm not sure what I'm doing wrong and I need assistance! I noticed that I can see the image if I use the <img> tag, but not when I try to set it as a ba ...

Include specific javascript files only for smartphones

Recently, I encountered an issue with a JavaScript code that swaps background images on scroll down. To address the problem with debounce, I ended up setting different debounce times for various browsers (I am aware this is not the ideal solution, but it&a ...

The flex box container has an overflowing issue despite the implementation of overflow:hidden and setting a min-width of

Struggling to make my flex box container fit in the div Despite setting min-width: 0 and overflow: hidden as a last resort the flex box simply won't shrink when the width changes Check out what happens when the width is adjusted: https://js ...

Having trouble with clicking a button in HTML?

I'm facing an issue with a button on my HTML page that features a background created using the popular particle library. The button is visible but not clickable. I've attempted adjusting the background size and alignment without success. How can ...

Ways to darken a theme when displaying a pop-up

I recently added a pop-up feature to my portfolio website and utilized Bootstrap classes to enhance its functionality. In order to make the pop-up object more prominent, I wanted to darken the background when opening the pop-up. However, some elements in t ...

Using Node.js with JavaScript to retrieve an element by its ID with the document

There is a Node.js script (app.js) that sends an email: const { response } = require("express"); const express = require("express"); const nodemailer = require("nodemailer"); const app = express(); const port = 5000; // funct ...

Issue with hiding div using jQuery's length option

I'm currently using Drupal 7.0 along with the Galleria Javascript Image Gallery in fullscreen theme. My theme includes two navigation buttons, and here is the CSS code for them: .galleria-image-nav { height: 159px; opacity: 0.8; position: fixed ...

Toggling back and forth between two divs using a pair of buttons

I've been experimenting with switching between two divs using two buttons, but I can't seem to get it right. I've searched all over the internet, but nothing has worked for me so far. Can you please point out what I might be doing wrong? Als ...

Tips for setting one image as the background for an entire page

Take a look at the web template image linked below: URL - https://ibb.co/cD3iH8 I want to utilize the abstract design image above as the background for an entire page. Please provide guidance on the most effective way to accomplish this task. ...

What is the best method for specifying CSS styles for a Vue.js component during the registration process?

Is it possible to register a custom Vue.js component using the following code? // register Vue.component('my-component', { template: '<div class="my-class">A custom component!</div>' }) For more information, you ...

Modify input field background color

In my Angular project, I have an input field structured like this: <input class="form-control" type="text" ng-model="newBook.color"> Whenever the value in this input changes, I want to dynamically change the background color of a specific div. Wit ...

css The issue of ul and ol elements not inheriting the padding property

https://codepen.io/unique-user123/pen/abcDeFG Why is it necessary to utilize the ul, ol, and li selectors in order to remove the default 40px left padding and 16px top and bottom margin? Can't we simply use the body selector to achieve this? <hea ...

What is preventing me from clicking on the left side of the link on this CSS flip card while using Chrome browser?

When attempting to click the left side of the link on the back of this flip card in Chrome, it does not respond. However, hovering over the right side allows interaction with the link: /* Vendor prefixed by https://autoprefixer.github.io */ .card { ...

Adjust the row based on the smallest picture

I am looking to create a photo grid using Bootstrap with images pulled from the Google Places API. The issue I am facing is that currently, the row adjusts to the height of the tallest image, but I want it to be the other way around. <div class="contai ...

Issue with navigating previous and next slides in Bootstrap carousel

I'm currently facing an issue where when I try to navigate left/right through pictures on my page, it ends up moving slightly downwards instead. Despite following a tutorial to resolve this problem, there seems to be a missing piece of code that I can ...

The design I created includes a horizontal scroll feature and certain elements are not properly aligned in the

Oh man, I'm really frustrated right now. I want all my elements to be centered horizontally on smaller devices, but some of them are slightly off to the side. And to top it off, there's a horizontal scroll appearing - it's like something is ...

Is there a way to shift the button over to the left?

I am currently utilizing the modalExample provided in the Bootstrap documentation. <button type="button" class="btn btn-primary" data-toggle="modal" data-target="#exampleModal">Open modal</button> <di ...

Corner of the Border Revealing a Clear Sky above

Looking to enhance my navigation bar (menu) by adding a cornered border when the user hovers over it. <nav> <a href="#home">Home</a> | <a href="#about">About</a> | <a href="#blog">Blog</a ...

The CSS content property within a style element prevents the dragging of elements

Is it possible to make an element with content draggable in HTML while changing the image through replacing the style of the element? I am trying to insert a picture using the content style tag, but it seems to make the element lose its draggable ability. ...