根据选项卡的高度使文本响应
Make text responsive according to how tall the tab is
How would I go about having my text be bigger, so my text goes to the bottom of the tab (without a scrollbar showing up or anthing) and when the tab gets smaller, make the font smaller.
h1 {
font-size: ?;
}
div {
length: according to browser;
}
您可以使用height: 100vh;
根据屏幕高度设置高度,对于font-size您可以使用@media queries
设置不同屏幕的字体大小。
body {
margin: 0px;
padding: 0px;
}
div.box {
height: 100vh;
background-color: #666;
}
h1 {
font-size: 50px;
color: #ffffff;
margin: 0px;
padding: 30px;
}
/* Extra small devices (phones, 600px and down) */
@media only screen and (max-width: 600px) {
h1 {
font-size: 25px;
}
}
/* Small devices (portrait tablets and large phones, 600px and up) */
@media only screen and (min-width: 600px) {
h1 {
font-size: 35px;
}
}
/* Medium devices (landscape tablets, 768px and up) */
@media only screen and (min-width: 768px) {
h1 {
font-size: 45px;
}
}
/* Large devices (laptops/desktops, 992px and up) */
@media only screen and (min-width: 992px) {
h1 {
font-size: 55px;
}
}
/* Extra large devices (large laptops and desktops, 1200px and up) */
@media only screen and (min-width: 1200px) {
h1 {
font-size: 65px;
}
}
<div class="box">
<h1>Karar Barcha</h1>
</div>
如果您想通过调整浏览器大小来改变大小,您可以使用 vw
代替 font-size
:
但是,对文本等元素使用 vw
意味着您可能希望对移动设备使用 media-queries
以避免非常小的文本,例如 <p>
元素。
h1 {
font-size: 4vw;
}
<body>
<h1>arman ebrahimi</h1>
</body>
How would I go about having my text be bigger, so my text goes to the bottom of the tab (without a scrollbar showing up or anthing) and when the tab gets smaller, make the font smaller.
h1 {
font-size: ?;
}
div {
length: according to browser;
}
您可以使用height: 100vh;
根据屏幕高度设置高度,对于font-size您可以使用@media queries
设置不同屏幕的字体大小。
body {
margin: 0px;
padding: 0px;
}
div.box {
height: 100vh;
background-color: #666;
}
h1 {
font-size: 50px;
color: #ffffff;
margin: 0px;
padding: 30px;
}
/* Extra small devices (phones, 600px and down) */
@media only screen and (max-width: 600px) {
h1 {
font-size: 25px;
}
}
/* Small devices (portrait tablets and large phones, 600px and up) */
@media only screen and (min-width: 600px) {
h1 {
font-size: 35px;
}
}
/* Medium devices (landscape tablets, 768px and up) */
@media only screen and (min-width: 768px) {
h1 {
font-size: 45px;
}
}
/* Large devices (laptops/desktops, 992px and up) */
@media only screen and (min-width: 992px) {
h1 {
font-size: 55px;
}
}
/* Extra large devices (large laptops and desktops, 1200px and up) */
@media only screen and (min-width: 1200px) {
h1 {
font-size: 65px;
}
}
<div class="box">
<h1>Karar Barcha</h1>
</div>
如果您想通过调整浏览器大小来改变大小,您可以使用 vw
代替 font-size
:
但是,对文本等元素使用 vw
意味着您可能希望对移动设备使用 media-queries
以避免非常小的文本,例如 <p>
元素。
h1 {
font-size: 4vw;
}
<body>
<h1>arman ebrahimi</h1>
</body>