有这样的事情,最小字体大小和最大字体大小? [英] Is there such a thing as min-font-size and max-font-size?
问题描述
我正在尝试在div中创建一个响应浏览器窗口的字体。到目前为止,它已经完美地工作了,但是父div有一个 max-width
525px
。进一步调整浏览器的大小不会使字体停止调整大小。这让我想知道是否有这样的事情: min-font-size
或 max-font-size
,如果有这样的事情不存在,如果有一种方法来实现类似的东西。
我认为使用百分比在 font-size
可以工作,但文本位不会相应地缩放到父div。这是我有:
为父div的CSS:
.textField {
background-color:rgba(88,88,88,0.33);
width:40%;
height:450px;
最小宽度:200px;
max-width:525px;
z-index:2;
$ / code $ / pre
$ b $ p 这段文字的CSS:
.subText {
position:relative;
top:-55px;
left:15px;
font-family:news_gothic;
font-size:1.3vw;
font-size-adjust:auto;
width:90%;
颜色:白色;
z-index:1;
$ b我在互联网上搜索了很长一段时间,但都无济于事。 解决方案不,没有最小或最大字体大小的CSS属性。浏览器通常有一个最小字体大小的设置,但这是在用户的控制下,而不是作者。
您可以使用 @media
查询进行一些CSS设置,具体取决于类似屏幕或窗口宽度。在这种设置中,你可以如果窗口非常窄,请将字体大小设置为特定的小值。
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.
解决方案 No, there is no CSS property for minimum or maximum font size. Browsers often have a setting for minimum font size, but that’s under the control of the user, not an author.
You can use @media
queries to make some CSS settings depending on things like screen or window width. In such settings, you can e.g. set the font size to a specific small value if the window is very narrow.
这篇关于有这样的事情,最小字体大小和最大字体大小?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!