Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Same size for all MudItem using MudBlazor

I'm trying in MudBlazor to make e-commerce style boxes where you can view image, product name and other information.

I am currently using the MudGrid with the related MudItem. See this example:

Problem displaying items in the grid

As you can see the height of the various MudItem is not the same for all, but it adapts according to the size of the image. I would like the MudItem to be all the same high and that they remain responsive (depending on the display device)

You can find the code here: https://try.mudblazor.com/snippet/GaGcYmmFziEpEAPJ

like image 938
Lorenzo Belfanti Avatar asked Sep 02 '26 19:09

Lorenzo Belfanti


2 Answers

I have the same issue, you need to do the following:

<MudGrid>
        <MudItem Style="display:flex;"> each card </MudItem>
        <MudItem Style="display:flex;"> each card </MudItem>
        <MudItem Style="display:flex;"> each card </MudItem>
</MudGrid>

Then you can adjust the content of each card. Also to avoid calling style everytime you could inject some css with one class.

like image 84
Leandro Toloza Avatar answered Sep 04 '26 15:09

Leandro Toloza


I was able to accomplish this by setting the MudItem style to display:flex and setting the MudCardContent style to min-height: 100px (in my case)

<MudPaper Width="100%" Class="darkbackground" MinHeight="350">
<MudContainer>
    <MudGrid>
        <MudItem xs="4" Style="display:flex;">
            <MudPaper Width="100%" Square="false" Class="pa-10 ma-2 infobox" Outlined="true">
                <MudCard>
                    <MudCardMedia Image="/images/rm/rm1.png" Height="200" />
                    <MudCardContent Style="min-height: 100px">
                        <MudText Class="textwhite" Typo="Typo.subtitle1">Always Evolving</MudText>
                        <MudText Class="textsilver" Typo="Typo.body2">Creating innovative new ways to trade the exchange markets</MudText>
                    </MudCardContent>
                </MudCard>
            </MudPaper>
        </MudItem>
        <MudItem xs="4" Style="display:flex;">
            <MudPaper Width="100%" Square="false" Class="pa-10 ma-2 infobox" Outlined="true">
                <MudCard>
                    <MudCardMedia Image="/images/rm/rm2.png" Height="200" />
                    <MudCardContent Style="min-height: 100px">
                        <MudText Class="textwhite" Typo="Typo.subtitle1">Is RainMaker Open Source?</MudText>
                        <MudText Class="textsilver" Typo="Typo.body2">RainMaker is not open source. Currently just a passion project</MudText>
                    </MudCardContent>
                </MudCard>
            </MudPaper>
        </MudItem>
        <MudItem xs="4" Style="display:flex;">
            <MudPaper Width="100%" Square="false" Class="pa-10 ma-2 infobox" Outlined="true">
                <MudCard>
                    <MudCardMedia Image="/images/rm/rm3.png" Height="200" />
                    <MudCardContent Style="min-height: 100px">
                        <MudText Class="textwhite" Typo="Typo.subtitle1">What is required to trade?</MudText>
                        <MudText Class="textsilver" Typo="Typo.body2">A broker account with Oanda.</MudText>
                    </MudCardContent>
                </MudCard>
            </MudPaper>
        </MudItem>
</MudGrid>
</MudContainer>
like image 35
Scott D Avatar answered Sep 04 '26 16:09

Scott D



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!