Home > Software engineering >  Blazor Virtualize Adds empty space in list before cards
Blazor Virtualize Adds empty space in list before cards

Time:08-04

If I use this code:

<div >   
        @foreach (var ski in skis)
        {
            <button  @onclick="(() => DetailSki(ski.Id))">
                @if (ski.Brand.Equals("Volkl"))
                {
                    <img src="images/volklmantra300.png" alt="Volkl Skis" style="width:100%" />
                }
                @if (ski.Brand.Equals("Head"))
                {
                    <img src="images/ski_image.png" alt="Head Skis" style="width:100%">
                }
                @if (ski.Brand.Equals("K2"))
                {
                    <img src="images/k2poacher300.png" alt="K2 Skis" style="width:100%" />
                }
                <div >
                    <h4>@[email protected]</h4>
                </div>
            </button>
        }
    </div>

enter image description here

Your grid has gap: 1rem; so it generates one extra gap between first div and first item and between last item and second div.

Also check this github issue where it is stated that Virtualize component does not work with display grid. Steve Sanderson suggests to use flex.

  • Related