Grid layout with Tailwind

I'm facing a challenge in my Angular project where I need to create a grid layout with 2 rows and 6 columns using Tailwind CSS.

The actors array that I am iterating through contains 25 actors. My objective is to show the first 12 actors in 2 rows, followed by a "show more" button to display the rest of the actors.

Currently, although I have specified 6 columns, there seems to be an issue with the rows as I am seeing 5 rows instead of the desired 2.

What could be causing this discrepancy?

HTML

<div class="grid grid-rows-2 grid-cols-6 mt-4 gap-4">
  <div *ngFor="let actor of actors" class="flex flex-col gap-2">
    <div class="w-full aspect-h-1 aspect-w-1 rounded overflow-hidden">
      <img src="{{actor.imageUrl}}" alt="Picture of actor">
    </div>
    <span class="text-white text-center">{{actor.name}}</span>
  </div>
</div>

Answer №1

This method doesn't seem to be effective in this case. A better approach would be to divide the "actors" array into segments of 12 items using the code snippet provided below, and display the remaining actors with a "show more" button.

<div *ngFor='let item of items | slice:start:end'>

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

Even after the component is destroyed, the subscription to the service observable continues to emit

I'm facing an issue with an observable in my service. The provided code below demonstrates this: @Injectable({ providedIn: 'root' }) export class MyService { public globalVariable: BehaviorSubject<string> = new BehaviorSubject(&ap ...

CSS must be applied to various sections of an HTML document

For example, I have 2 CSS files. In one CSS file, I have the style: a{color: blue;} In the second file, I have: a{color: red;} I want to apply these styles to my HTML file. <div> <a>first file ...

Having trouble with Image and Css not displaying correctly when using CodeIgniter 3 with DomPDF?

I'm currently utilizing CodeIgniter 3 and dompdf to convert an HTML view into a PDF. While I am able to successfully convert the HTML to PDF, the proper styling is not being applied. All necessary CSS files have been included as custom design in the v ...

Injecting Services Error in Angular

I'm in the process of developing a web App and recently put together a new service: import { Injectable } from '@angular/core'; @Injectable({ providedIn: 'root' }) export class ModuleService { constructor(private startTime: ...

Exploring the concept of Server-Side Rendering in AngularIO

Exploring the fundamentals of SSR and AngularIO (latest version) has been quite enlightening. The distinction between CSR and SSR seems obvious based on their names. CSR carries out all the logic in the client side - for example, <app-route> remains ...

When running the `npm run dev` command, Tailwind does not seem to function

I have been given a task to create forms using tailwindcss, but when I try to run `npm run build`, it doesn't work. Can anyone assist me with this? npm ERR! code ELIFECYCLE npm ERR! errno 9 npm ERR! <a href="/cdn-cgi/l/email-protection" class="__cf ...

Creating dynamic navbar links in Vue.jsIn this guide, we will explore how to give the active

My goal is to assign a different color to each menu item when it's active. I've tried to achieve this by following these two code examples: 1 -> https://codepen.io/Ranushka/pen/KKPBYQv 2 -> https://codepen.io/Ranushka/pen/ZEzjdrO However ...

Tips for creating a navigation bar that bypasses body padding in HTML and CSS

I have set padding in my 'body' tag, but I want my top navigation bar to cover the entire page without being affected by it. I attempted to fix this by setting the width to 100% and using negative padding and margin values, but it did not work a ...

How can you ensure an element's height matches its width within an Ionic framework?

I am currently creating an application using the Ionic framework, and I am looking to set a square image as the background. The challenge is to ensure that the image scales appropriately for different screen resolutions; ideally, it should occupy the full ...

The Vue Swiper does not support inline containers in my code

I am facing an issue with the layout of my simple swiper in my vue app. The containers are not inline as expected, causing the second one to appear under the first. Additionally, I am struggling with making the slider element visible only within the viewpo ...

What is the best way to create a dynamic URL linking to an external site in Angular 5?

When attempting to create a link like this: <a [href]="getUrl()">click me</a> getUrl() { return this.domSanitizer.bypassSecurityTrustUrl('http://sampleUrl.com'); } The link is not clickable. When hovering over the ...

"Enhance your user experience with dual notifications using the Angular2-to

Whenever I utilize the angular2-toaster packages, I find myself receiving duplicate notifications. Below is an example showcasing the usage of this package. I am unsure why this issue occurs, but I have noticed that simply reloading my angular2 applicatio ...

The identification of the field is not being transmitted by ng-select

Looking for help with Angular! I have an ng-select box where I can choose countries, and it's working fine when I select an option and submit - it submits the id as expected. However, when pre-populating the ng-select with data and submitting, it&apos ...

When scrolling down a webpage, the background color of the content does not stretch along with the page

I've created a webpage with a sticky header and footer, along with a scrollbar on the main content. However, I'm facing an issue where the background color of the content does not extend beyond the viewport when scrolling down. The text is visibl ...

Achieve a flat text indentation similar to an ordered list using CSS

Is there a way to format my FAQ Q & A like an ordered list? <div class="col-left"> <h3><strong>CAPTION</strong></h3> <ul> <li>Q: Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Sed non risus. Suspe ...

Transform the look of an inactive hyperlink

Can the visual style of an HTML link be modified when it is disabled? For instance, by implementing something like this: a.disabled { color:#050; } <a class="disabled" disabled="disabled" href="#">Testing</a> The code snippet above appears ...

CSS3 animations and transitions offer dynamic and engaging effects for websites

Could CSS3 animations be utilized for scrolling a window? In jQuery, you would typically use something like: $(window).animate({scrollTop: '+=200'}, 300, function() { }); Therefore, my inquiry is whether it is feasible to achieve a similar effe ...

Tips for modifying hover effects using jQuerystylesheet changes

I attempted running the following code snippet var buttonElement = $('<button>Button</button>'); $('body').append(buttonElement); buttonElement.hover().css('background-color', 'red'); Unfortunately, the ...

Securing Your Angular 2 / ASP.NET MVC Application from CSRF Attacks

I am currently developing a single-page application using ASP.NET MVC for the backend and Angular 2 for the frontend. To prevent cross-site request forgery attacks in my application, I have implemented the following steps: Since ASP.NET MVC sends a co ...

CSS for mobile devices not loading until the device is rotated

My website, redkrypt.com, is functioning perfectly on my laptop. However, I am facing an issue where the css file will only load on my iPhone 4S after I rotate it once. Once I do this, the website works both vertically and horizontally. I have tried variou ...