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.
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.
2
Answers
Solution #1
Using only CSS, you can create two divs and set the width range in which they are visible.
Solution #2
You can fill the content of the div using
::before
or::after
pseudo-elements.Have you tried adding the "resize" Event using JavaScript.
You can use the following code to add it after getting the element.