Home > database >  Switching styles in CSS, under the specified conditions laravel
Switching styles in CSS, under the specified conditions laravel

Time:12-28

I need to specify my styles under certain conditions

<div >
                @foreach($topServers as $server)
                    <div >
                        <div >
                            @foreach($guilds as $guild)
                                @if($server->id == $guild->id)
                                    <img  src="..." alt="">
                                @endif
                            @endforeach
                        </div>
                    </div>
                @endforeach
            </div>

Provided that $server->premium >= 1, you need to specify the "border-color:gold" styles in the div

And I absolutely do not understand how to implement it, thank you in advance for your help

CodePudding user response:

Just use a ternary to add a style.

<div  {{ $server->premium >= 1 ? 'style="border-color:gold"' : '' }}>
  • Related