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="container">
    <div class="row row-eq-height" ng-repeat="images in main.slicedImages">
        <div class="col-lg-3 col-md-3 col-sm-3 col-xs-3" ng-repeat="image in images">
            <div class="hovereffect" ng-click="selected = !selected">
                <img ng-class="{ 'selected_image': selected }" ng-src="{{image.img}}" class="img-responsive stretch_image">
                <div class="overlay">
                    <a class="info" ng-bind="image.name"></a>
                </div>
                <a class="selected_text" ng-show="selected">SELECTED</a>
            </div>
        </div>
    </div>
</div>

Currently, the layout looks like this: https://i.stack.imgur.com/u5nhb.png I would like the rows to adjust to the size of the images on the right, even if it means cropping larger images rather than resizing them.

Answer №1

To control the dimensions of an image using CSS, you can utilize the max-width and max-height properties set to 100%.

.my_custom_img_class {
   max-width: 100%; 
   max-height: 100%;
}

<img ng-class="{ 'highlighted_image': highlighted }" ng-src="{{picture.url}}" class="responsive_image custom_img_class">

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

What is the best way to determine the actual height of a DOM element that is being hidden by the overflow property in order to create a seamless CSS transition to height: auto

Solution: Thanks to @Kalimah, here's a solution that works in composition api & script setup: <script setup> const state = reactive({ meetCardHeight: 100 }) const element = ref(null) const changeElementHeight = () => { if (stat ...

What is the recommended sequence for adding AngularJS to the index page?

I am new to AngularJS and currently working on a project where I need to include multiple JavaScript files in my index.html page. After doing some research, I came across a post on Stack Overflow that mentioned the importance of including the angular.js fi ...

The Bootstrap 5 navigation bar does not extend to the full width of its parent

While working on a Bootstrap navigation inside a container, I encountered an issue where the navigation bar was not expanding to match the width of the container. It seemed like the padding had to be manually adjusted to fit properly. Below is the code sn ...

Issue with Bootstrap 5 offcanvas when placed inside a fixed div

I am currently incorporating the bootstrap navbar with offcanvas functionality. All nested within a fixed positioned div. The styling of the div is outlined below: .whiteHeader { position: fixed; display: flex; align-items: center; height: ...

Convert JavaScript code to Google Appscript

Looking for guidance on incorporating Javascript code into my Google Appscript. Here is the code snippet: I have a separate Stylesheet.html file saved. Can someone advise me on how to invoke the functions within the html file? <script> //google. ...

Customize your AutoComplete with MUI styling

Upon taking over a project, I found myself working with material ui for the first time. Here is an excerpt from my code: <FormControl fullWidth> <InputLabel className={className} htmlFor={id} error={error} > ...

Having trouble implementing button functionality in a web app using JS, jQuery, HTML, and CSS along with an API integration

I am currently developing a web search engine that utilizes the Giphy API... However, I've encountered difficulties with the button function. I have created buttons to modify the page format and adjust the number of search results displayed.... The We ...

Steps for making a button with both an image and text:

I am in the process of designing a basketball-themed website and I am looking to incorporate custom icons/buttons that link to various pages on the site. My vision is to have a unique button that features a circular image with accompanying text below it. ...

React component rendering twice due to width awareness

In a React component that I've developed, I have utilized ResizeObserver to track its own width. Within this component, two divs are rendered with each having a "flex: 1" property to ensure equal width distribution. Under certain conditions, such as w ...

The dropdown hack on ui.bootstrap.typeahead is compromised when multiple input fields are used in AngularJS

I attempted to enhance ui.bootstrap.typeahead with a hack that adds a dropdown functionality. I discovered the hack on this site. The modification allows the dropdown to appear when clicking inside the input field. Although it functioned appropriately with ...

What is the process for converting a hexadecimal color to rgba when using the Less compiler?

Here's the code snippet I'm working with: @shade : #d14836; .stripes span { -webkit-background-size: 30px 30px; -moz-background-size: 30px 30px; background-size: 30px 30px; background-image: -webkit-gradient(linear, left top, ri ...

Code snippets to reduce excess white space on a website using HTML and CSS

On my website, there are multiple tabs, each containing content from an HTML file. When a user clicks on Tab1, boxes with images are displayed. The layout can be seen in the following Code Demo: Code Demo here There seems to be extra space before and afte ...

Is there a way to achieve a double background color effect in CSS while ensuring that the text is centered within the second background color element?

How can I achieve a layout similar to the one shown in this image: ul menu li tags Should I use two tags for each element? Here is an example: <ul class="menu"> <div class="outside"><li class="inside"><a href="#">Firefox</a ...

Creating a horizontal layout for list items that are responsive using CSS

My website has a "Featured" section with 3 equally sized elements displayed horizontally. I want to make the webpage responsive by using percentage widths, but when I resize the window to less than the list width, the items stack on top of each other. Che ...

Error encountered when installing angular 8 components due to package conflicts

Having Trouble Building .NET Core + Angular Project I have encountered an unfamiliar project that requires minor fixes. I attempted to build it with the following command: dotnet publish -c Release -r win-x64 --self-contained false --output "D:&bso ...

Denied access to [Any Url] as it breaches the specified Content Security Policy directive and refused to connect

Struggling to retrieve data using the Login() method within a post request, but encountering an error when the URL is transferred to its destination. Error: Refused to connect to 'http://smartlearner.com/SmartLearner/UserAccount/[email prote ...

Mobile Safari is having troubles loading CSS

After a long time of using in-line CSS directly on the page, I finally decided to consolidate it all into one file for my own sanity. Initially, I attempted the standard <link rel="stylesheet" href="URL"> approach and it loaded successfully, alt ...

How can I reverse the names displayed in ng-repeat when I click?

When utilizing the orderby filter in angularjs, I want to be able to sort the data only when the button is clicked. If the button is not clicked, the sorting order should not be displayed. <tr ng-repeat="tools in toolsfilter | orderBy:orderByField:reve ...

Leverage CSS to create a hover effect on one element that triggers a change in another

How can I use pure CSS to make an image appear when hovering over text? HTML <h1 id="hover">Hover over me</h1> <div id="squash"> <img src="http://askflorine.com/wp-content/uploads/2013/10/temp_quash.jpg" width="100%"> </div&g ...

Enhancing caching through JSPM optimization

I have successfully configured my workflow to utilize JSPM, resulting in the creation of a production bundle consisting of two large injected and hashed files called main-{hash}.min.css and main-{hash}.min.js. My inquiry pertains to the efficiency of sepa ...