缩放字体大小与屏幕尺寸? [英] Scaling font size with screen size?
问题描述
我正在使用AngularJS 1.x和Angular Material开发一个网络应用程序。我正在尝试在 md-display-4
创建一个大标题的目标网页。
这里是它看起来像:
如您所见
但是,这是在一个1680x1050的显示器上。如果我将浏览器窗口移动到较小的1366x768显示器,我会得到这个:
正如你所看到的,字体保持相同的物理大小,超出了下一行,也不再居中。
这是我的代码:
< html>
< head>
< title> FOOBY DOOBY< / title>
< link rel =stylesheethref =http://ajax.googleapis.com/ajax/libs/angular_material/1.1.0-rc2/angular-material.min.css> ;
< link rel =stylesheethref =https://fonts.googleapis.com/css?family=Roboto:300,400,500700,400italic>
< link rel =stylesheethref =styles.css/>
<! - Angular材质需要Angular.js库 - >
< script src =http://ajax.googleapis.com/ajax/libs/angularjs/1.5.3/angular.min.js>< / script>
< script src =http://ajax.googleapis.com/ajax/libs/angularjs/1.5.3/ rectangular-animate.min.js>< / script>
< script src =http://ajax.googleapis.com/ajax/libs/angularjs/1.5.3/angular-aria.min.js>< / script>
< script src =http://ajax.googleapis.com/ajax/libs/angularjs/1.5.3/angular-messages.min.js>< / script>
<! - 角材料库 - >
< script src =http://ajax.googleapis.com/ajax/libs/angular_material/1.1.0-rc2/angular-material.min.js>< / script>
< script src =app.js>< / script>
< / head>
< body ng-app =homePage>
< div layout =column>
< div layout layout-align =center>
< h1 class =md-display-4> FOOBAR是此处的标题< / h1>
< / div>
< div>
<! - Description here - >
< / div>
< / div>
< / body>
< / html>
您可以使用视口单位, p>
h1 {font-size:10vw;}
foobar是这里的标题< / h1>
I'm developing a web app with AngularJS 1.x and Angular Material. I'm trying to create a landing page with a large title at md-display-4
.
Here's what it looks like:
As you can see, the title fills the page nicely and fits in one line.
However, this is on a 1680x1050 monitor. If I move the browser window to my smaller 1366x768 monitor, I get this instead:
As you can see, the font stays the same physical size and overruns to the next line, and also is no longer centred.
How can I ensure a consistent look where font scales depending on screen size?
Here's my code:
<html>
<head>
<title>FOOBY DOOBY</title>
<link rel="stylesheet" href="http://ajax.googleapis.com/ajax/libs/angular_material/1.1.0-rc2/angular-material.min.css">
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Roboto:300,400,500,700,400italic">
<link rel="stylesheet" href="styles.css" />
<!-- Angular Material requires Angular.js Libraries -->
<script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.5.3/angular.min.js"></script>
<script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.5.3/angular-animate.min.js"></script>
<script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.5.3/angular-aria.min.js"></script>
<script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.5.3/angular-messages.min.js"></script>
<!-- Angular Material Library -->
<script src="http://ajax.googleapis.com/ajax/libs/angular_material/1.1.0-rc2/angular-material.min.js"></script>
<script src="app.js"></script>
</head>
<body ng-app="homePage">
<div layout="column">
<div layout layout-align="center">
<h1 class="md-display-4">FOOBAR IS THE TITLE HERE</h1>
</div>
<div>
<!-- Description here -->
</div>
</div>
</body>
</html>
You can use viewport units, for example:
h1 {
font-size: 10vw;
}
<h1>Foobar is the title here</h1>
这篇关于缩放字体大小与屏幕尺寸?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!