There are 2 things you can do; neither use w3.css but function just fine; one of which does use vw
as a unit but should work out
Option 1
you can use
@media screen and (min-width: any_size){}
.
Which works like this:
/* if the screen is wider than 500px set the font size to 80px */
@media screen and (min-width: 500px) {
.dynamicallyScale {
font-size: 80px;
}
}
/*if the screen size is less than 499px set the font size to 80px */
@media screen and (max-width: 499px) {
.dynamicallyScale {
font-size: 30px;
}
}
<link href="https://www.w3schools.com/w3css/4/w3.css" rel="stylesheet"/>
<table class="w3-container w3-table">
<tr>
<td>
<h2 id="date1" class="dynamicallyScale"><b>title1</b></h3>
</td>
<td class="w3-black w3-center">
<h3 class="dynamicallyScale">title2</h3>
</td>
<td class="w3-center">
<h3 class="dynamicallyScale">title3</h3>
</td>
<td class="w3-center">
<h3 class="dynamicallyScale">title4</h3>
</td>
<td class="w3-center">
<h3 class="dynamicallyScale">title5</h3>
</td>
</tr>
</table>
Needless to say, you can also use any other way of defining size such as em
and %
However, this change is really abrupt and will require a lot, and I mean a lot of min-width:
and max-width:
statements to look smooth so will probably require a whole separate CSS file to work and is, in general, just a bad coding practice.
Option 2
You can use the vw
unit. This dynamically scales the text size depending on the size of the viewport width(which is what vw
stands for). so you could do something a little bit like this:
<link href="https://www.w3schools.com/w3css/4/w3.css" rel="stylesheet"/>
<table class="w3-container w3-table">
<tr>
<td>
<h2 id="date1" style="font-size:8vw;"><b>title1</b></h3>
</td>
<td class="w3-black w3-center">
<h3 style="font-size:6vw;">title2</h3>
</td>
<td class="w3-center">
<h3 style="font-size:4vw;">title3</h3>
</td>
<td class="w3-center">
<h3 style="font-size:2vw;">title4</h3>
</td>
<td class="w3-center">
<h3 style="font-size:1vw;">title5</h3>
</td>
</tr>
</table>
Of course you could use other sizes than in my example but you should see that if you resize the window the text size dynamically changes. While this doesn't use w3.css it is the best possible solution.