I'm trying to make a font in a div responsive to the browser window. So far, it has worked perfectly, but the parent div has a max-width
of 525px
. Resizing the browser further will not make the font stop resizing. This has made me wonder if there is such a thing as min-font-size
or max-font-size
, and if such a thing does not exist, if there is a way to achieve something similar.
I thought that using percentages at font-size
would work, but the bit of text won't scale accordingly to the parent div. Here's what I have:
The CSS for the parent div:
.textField{
background-color:rgba(88, 88, 88, 0.33);
width:40%;
height:450px;
min-width:200px;
max-width:525px;
z-index:2;
}
The CSS for the piece of text in question:
.subText{
position:relative;
top:-55px;
left:15px;
font-family:"news_gothic";
font-size:1.3vw;
font-size-adjust:auto;
width:90%;
color:white;
z-index:1;
}
I have searched for quite a while on the internet, but to no avail.
This is actually being proposed in CSS4
Working draft at the W3C
Quote:
This would actually work as following:
This would literally mean, the font size will be 5% of the viewport's width, but never smaller than 10 pixels, and never larger than 18 pixels.
Unfortunately, this feature isn't implemented anywhere yet, (not even on caniuse.com).
I got some smooth results with these. It flows smoothly between the 3 width ranges, like a continuous piecewise function.
Yes, there seems some restrictions by some browser in SVG. The developertool restrict it to 8000px; The following dynamically generated Chart fails for example in Chrome.
Try http://www.xn--ffffdelei-n2a.de/2018/test-von-svt/