Struggling with the alignment of pictures inside a container

I utilized the Instafeed.js library to fetch the three most recent images from an Instagram account. These images are loaded into a specific div and I successfully customized their styling according to my requirements. However, the current setup is quite static. When viewed on a larger screen, the images appear in a row of three and are not aligned properly. Additionally, if one of the images is wider than it is tall, it does not align correctly with the larger image on the left, resulting in an awkward display. Below, you can see a screenshot of how it appears on my MacBook (which is how it should always look regardless of screen or image dimensions), as well as another screenshot showing how it looks on a bigger screen. Any assistance on resolving this issue would be greatly appreciated!

Desired Layout:

Current Display on Bigger Screen:

Instafeed Configuration:

  var feed = new Instafeed ({
    get: "user",
    userId: "1957779802",
    limit: 3,
    sortBy: "most-recent",
    resolution: "standard_resolution",
    template: '<div class="img"><a href="{{link}}"><img src="{{image}}" /></a></div>',
    accessToken: "1957779802.bef71cd.f6782544ba674fc3af9dddb2fec415fe"
  });
  feed.run();

HTML Structure:

<div class="col2">

      <div id="instafeed"></div>

      <div class="acell">
        <div class="contentbox">
          <a href="https://www.youtube.com/channel/UCQEXfLzrNpxe7AZme3dTP0w" target="_blank"><img class="yt-bg" src="<?php bloginfo('stylesheet_directory'); ?>/images/youtube-img.jpg" alt="Youtube" /><span class="covered"><div class="play"><img src="<?php bloginfo('stylesheet_directory'); ?>/images/play-img.png"></img></div><div class="text"><h3>Press Play!</h3><p>Watch clips on our YouTube channel.</p></div></span></a>
        </div>
      </div>
    </div>

CSS Styling:

.social-container .row1 .col2 .instafeed {
  width: 100%;
  height: auto;
}

.social-container .row1 .col2 .img {
  margin: 5px;
  height: auto;
  width: auto;
  float: left;
  text-align: center;
}

.social-container .row1 .col2 .img a img {
  display: inline;
  border: 1px solid #ffffff;
}

.social-container .row1 .col2 .img a img {
  width: 150px;
  height: 152px;
}

.social-container .row1 .col2 .img:first-child {
  margin-right: 30px
}

.social-container .row1 .col2 .img:first-child a img {
  width: 330px;
  height: 320px;
}

Answer №1

To achieve a responsive design, you need to move away from fixed widths and embrace percentages for sizing elements that can scale up accordingly. Utilizing @media queries in your stylesheet will allow you to target specific display widths and adjust styles accordingly. However, keep in mind the resolution limitations of your images when scaling up beyond a certain size. You can use @media screen and (min-width: 1440px) or set max-width on images to control how they appear on larger screens. Making your site truly responsive may take some time and effort, but the end result will be worth it.

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

Refresh a particular element using javascript

I'm new to Javascript and I am trying to refresh a specific element (a div) using only Javascript when that div is clicked. I came across the location.reload() function, but it reloads the entire page which doesn't fit my requirements. Upon clic ...

Chromium is having issues with updating the dynamic source attribute

One portion of my script that pertains to the question is as follows: <script type="text/javascript> function handleImageClick() { var image = $("#image_id"); $(image).attr("src", "ajax-loader.gif"); $.ajax({ ...

Automatically assign personalized metadata to WooCommerce orders according to the payment method used

I recently customized the WooCommerce admin order pages by adding a select field to the order details section. Here's how I did it: add_action('woocommerce_admin_order_data_after_order_details', 'display_option'); function display_ ...

Node application experiencing issues retrieving SVG files during production

When testing my application locally, the svg files display correctly with the code below (Angular.js variables are used within curly brackets): <img ng-src="img/servant_{{servant.personality}}.svg" draggable="false"> However, once deployed on Herok ...

What is the best way to send a message to only one specific client using socket.io instead of broadcasting to everyone?

After thoroughly researching the documentation, I am still unable to find a solution. My goal is to send data to a specific client or user instead of broadcasting it to everyone. I have come across other inquiries regarding this issue, but most either rem ...

Display or conceal a div based on checkbox selection

I am trying to implement functionality to show/hide a div when a single checkbox is selected. Currently, it works with "Select all" but I am struggling to make it work with a single checkbox. Below is the code for "Select All": JS: <script language=&a ...

Exploring anchor elements within a div using Selenium in Python to extract URLs

Hey there, I'm currently attempting to iterate through anchor elements within a div and retrieve the links of these elements. <div class="List"> <a class="selected" href="link">text 1</a> <a ...

Is it possible to bring in a `devDependency` into your code?

The Mobx DevTool's README instructs users to install it as a dev dependency, and then import it into their code. This approach raises concerns for me because devDependencies are typically reserved for tools used in the build process or managing end co ...

change the css back to its original state when a key is pressed

Is there a way to retrieve the original CSS of an element that changes on hover without rewriting it all? Below is my code: $(document).keydown(function(e) { if (e.keyCode == 27) { $(NBSmegamenu).css('display', 'none');} ...

In order to properly adjust the HTML content when resizing the window, it

I'm facing an issue with a toggle setup for displaying content differently based on screen width. Specifically, when the screen size decreases below 600px, it switches to the correct content. However, upon increasing the screen width again, it fails t ...

Implementing jQuery to showcase an element on the screen

I would like to express my gratitude to everyone who has helped me. Please forgive my poor English :) Can someone provide me with a jQuery script that can extract the name of the currently selected tab and display it in an h1 tag? Whenever the selected ta ...

Using TypeScript to filter and compare two arrays based on a specific condition

Can someone help me with filtering certain attributes using another array? If a condition is met, I would like to return other attributes. Here's an example: Array1 = [{offenceCode: 'JLN14', offenceDesc:'Speeding'}] Array2 = [{id ...

Issue with white spaces in footer content in Chrome browser

Currently in the process of developing a website and encountering a strange bug that only seems to be affecting Chrome. Despite having the latest version of Chrome, it appears to be an issue that was prevalent in older versions (v18 - v20). The problem is ...

The drop-down menu does not maintain its selected option after the window is refreshed

I am struggling with a dropdown list as shown below: <select class="span2" id ="sort" name= "order_by"> <option >Default</option> <option >Price</option> <option >Color</option> ...

When rendering in React, the output of a multidimensional object may appear as undefined

Currently experiencing a challenge with a React application that I am developing. I am attempting to display data on the screen, however, there are instances where an object key is not available. For example: <div> <TableRow> <TableCel ...

Why doesn't express.js throw an error when the variable 'app' is used within its own definition?

When working with express.js, I find it puzzling that createApplication() does not throw an error. This is because it uses app.handle(...) within an anonymous function that defines the same variable 'app'. I attempted to replicate this in jsFidd ...

Adjusting the height of the navbar items to align with the size of the

In the bootstrap navbar below, I am trying to enlarge the search field to be large using 'input-lg', but this causes the other items in the navbar not to vertically center correctly. How can I align the other items in the navbar with the large in ...

Tips for updating the minimum value to the current page when the button is pressed on the input range

When I press the next button on the current page, I want to update the value in a certain way. https://i.stack.imgur.com/XEiMa.jpg I have written the following code but it is not working as expected: el.delegate(".nextbtn", "click", f ...

What is the method for iterating through rows using csv-parser in a nodejs environment?

I'm working on a script to automate the generation of code for my job. Sometimes I receive a .csv file that contains instructions to create table fields, sometimes even up to 50 at once! (Using AL, a Business Central programming language.) Here is th ...

Utilizing the Bootstrap grid system for responsiveness is optimized for a first word that is precisely 15 characters

Trying to achieve responsiveness using basic Bootstrap. The layout becomes responsive only when the initial word in a sentence contains more than 15 characters, as illustrated below. https://i.stack.imgur.com/wyErA.png <!-- Headers --> <div clas ...