Ensuring uniformity in picture size while uploading images in Angular by resizing and including white borders

Currently, I am working with pictograms and I am looking to showcase all the pictograms that the user has in both grid list and grid tiles formats. However, the challenge lies in the fact that the aspect ratio of the pictograms varies significantly depending on the specific image. https://i.sstatic.net/RdleM.png To address this issue, I am currently using ng2-img-max to resize the pictograms while preserving their original ratio. While I am fairly new to CSS, I have attempted some solutions like setting max-width to 80% and experimenting with different approaches. Nevertheless, I believe that the optimal solution would involve adding white borders to the pictograms to standardize them to a 300px*300px dimension, making it easier to manage their display.

Answer №1

I stumbled upon an excellent tutorial about creating responsive layouts using CSS grid which I personally found very helpful.

<div class="grid-container" fxFill>

  <div>
// INSERT ANY CONTENT HERE -- TILE 1
  </div>

  <div>
// INSERT ANY CONTENT HERE -- TILE 2
  </div>

  <div>
// INSERT ANY CONTENT HERE -- TILE 3
  </div>

</div>

Here is the SCSS code for that:

.grid-container {
  display: grid; // sets display to grid
  width: 100%; // fills the container's width
  grid-template-columns: repeat(auto-fit, minmax(12rem, 1fr)); 
  padding: 0px; // personal preference
  grid-column-gap: 30px; // personal preference
}

The key part here is the 'grid-template-columns` property. You can learn more about its different settings here.

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

Reconfigure an ancestral item into a designated key

I have a single object with an array of roles inside, and I need to transform the roles into an array of objects. See example below: Current Object: displayConfiguration: { widgetList: { widgetName: 'widget title', entityType: 'As ...

What is the reason for the image not being positioned in the top left corner of the html page?

My simple HTML page consists of only one image: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>Anz ...

The marquee HTML code is not functioning correctly in the Chrome browser

<marquee behavior="scroll" scrollamount="2" direction="right" width="70%" style="background-color: transparent; height: 18px;" onmouseover="this.stop();" onmouseout="this.start();"> 1 2 3 4 5 6 7 //inside html </marquee> Th ...

Navigational Menu in PHP

My goal is to have one link that retrieves data from a table with a specific value and another identical link that pulls data from the same table but with a different value. However, both dropdowns are displaying in the link. <div class="col-sm-9"> ...

Tips for creating a unit test case for a specialized validator in angular reactive forms

Looking for guidance on creating a test case for this specific method: export class CustomErrorStateMatcher implements ErrorStatematcher { isErrorState(control: FormControl,form:NgForm | FormGroupDirective | null){ return control && control.inval ...

Switch between two AppBars simultaneously while scrolling in Material UI

In my Header.js component, I have two AppBars. The first one is sticky and the second one is not initially visible. As we scroll down, I want the second AppBar to collapse and the first one to stay stickied at the top of the screen. I looked at the Materi ...

Effective RxJS Subscription Management - Minimize Unnecessary Subscriptions

What strategies can I implement to prevent subscribing excessively? Is there a way to automatically unsubscribe any active subscriptions? clickDown(e) { this.mouseMoveSubscription = fromEvent(this.elementRef.nativeElement, 'mousemove') .s ...

Issues with HTML5 tag <animate> in Internet Explorer 11

After getting the hang of some HTML basics, I decided to get creative and make an animation. Surprisingly, it works perfectly on my Firefox browser. However, when I tested it on IE 11, it failed to play the animation as expected. Everything is displayed bu ...

The art of positioning images and creatively cropping

Seeking advice on allowing users to dynamically position and clip an image on a webpage. I've tried using CSS and JavaScript for clipping and resizing, but it's not working as expected. If PHP could provide a solution, that would be ideal for my ...

How can I adjust two overlapping divs for proper display?

It seems like I have two divs overlapping on the same line. The layout appears fine on a PC but not on an iPad or mobile device. Can someone please review the code and point out any mistakes I might have made? The issue is with the content overlapping the ...

What are some effective strategies to ensure my header is aligned properly on both mobile and desktop platforms?

While I'm more focused on back end web development, I've been struggling to make my header look good on both mobile and desktop without resorting to creating separate sites for each. This approach has proven to be cumbersome as maintaining two si ...

What is the best way to activate the cube portfolio using custom jquery?

Is there a way to activate the Cube portfolio filter using custom JQuery? see image here For instance: In my Cube portfolio slider, I have over 20 projects featuring different technologies. When I slide the div, I want the filter to be activated based on ...

Troubleshooting issue with Angular2 Dart ngFor not refreshing view with WebSockets data stream

Recently, I've been facing an issue with an Angular2 component. Whenever I use websockets, the view fails to update properly. Interestingly, everything runs smoothly when I make http requests, but I really need to ensure that the data in the view stay ...

Guide to expanding the sidebar width

As I delve into the world of CSS, I find myself puzzled by the issue of expanding the sidebar to ensure that the "Gestion des utilisateurs" section appears on a single line. https://i.stack.imgur.com/xzFEA.png To provide context, I have included an illus ...

The age-old debate: Ngxs or Behavior Subject, which one should you go

I'm embarking on creating an admin panel for a Payment gateway product using Angular's latest version, working with a multitude of microservices. With experience in NGXS state management, as well as subjects and behavior subjects, I'm undeci ...

How can I eliminate padding from events in FullCalendar's timeGrid view?

Is there a way to remove the padding from an event when the calendar is in 'timegridview'? Users are taking advantage of the empty space created, allowing them to bypass a blocked time slot. I currently have it set so that clicking on an event d ...

What is the best way to customize CSS in Material UI?

When working with material UI and reactjs, I encountered an issue while trying to override the button color without affecting the tab colors (see screenshot). How can I achieve this using themes in material UI? Code: const theme = createMuiTheme({ p ...

What could be causing the images to not display on my HTML page?

My program is designed to display an image based on the result of the random function. Here is my HTML: <div> <h2>Player 0:</h2> <div id="MainPlayer0"></div> </div> Next, in my TypeScript fi ...

Obtain the Vertical Dimension of an HTML Element using

Recently, I developed a unique modal message window for my application. However, I am facing an issue in determining the height of the container that is inserted into the overlay. function load_custom_message(title, message) { var left = (($(window).wi ...

Receiving a null value when attempting to access the ids of dynamically created HTML elements using JavaScript

Encountering issue with accessing ids of dynamically generated HTML elements using javascript In my current project, I am attempting to dynamically alter the ids of div elements and remove buttons that are appended to the parent div. The desired functiona ...