I need to execute different code blocks based on the window width. When the width is 500px or more, I want to run a specific block of code, and when it's 499px or less, I need another block of code to run. How can I achieve this?
For widths of 500px or more:
<div class="card text-center d-inline-block m-2" style="width: 13rem;" >
<img src=".." class="card-img-top" alt="...">
<div class="card-body">
<h5 class="card-title" style="font-size: 1rem;">name</h5>
<p class="card-text text-muted" style="font-size: 0.8rem;">100 $</p>
<a href="#" class="btn btn-primary" style="font-size: 0.9rem;">watch</a>
</div>
</div>
For widths of 499px or less:
<div class="card mb-3" style="max-width: 540px;">
<div class="row g-0">
<div class="col-md-4">
<img src="..." class="img-fluid rounded-start" alt="...">
</div>
<div class="col-md-8">
<div class="card-body">
<h5 class="card-title">Card title</h5>
<p class="card-text">This is a wider card with supporting text below as a natural lead-in to additional content. This content is a little bit longer.</p>
<p class="card-text"><small class="text-muted">Last updated 3 mins ago</small></p>
</div>
</div>