I want to change the Value of <p>
tag "text" when the page resize (shrink or grow).
<div className='flex sm:bg-red-500/40 after:sm:content-["I am sm Size"]'>
This is a Test
</div>
However, when I resize the page, it doesn't work.
Using only CSS, you can create two divs and set the width range in which they are visible.
<script src="https://cdn.tailwindcss.com"></script>
<div>
<p class="sm:hidden">This is a Test</p>
<p class="hidden sm:block">I am sm Size</p>
</div>
You can fill the content of the div using ::before
or ::after
pseudo-elements.
<script src="https://cdn.tailwindcss.com"></script>
<div class="after:content-['This_is_a_Test'] sm:after:content-['I_am_sm_Size']">
</div>