gpt4 book ai didi

css - 根据 div 大小调整字体大小

转载 作者:技术小花猫 更新时间:2023-10-29 10:13:27 24 4
gpt4 key购买 nike

<分区>

它由 9 个盒子组成,中间有文字。我已经这样做了,所以盒子会随着屏幕大小的调整而调整大小,这样它就会一直保持在同一个地方。

然而,文本不会调整大小 - 即使我使用百分比也是如此。

  1. 如何调整文本大小,使其在整个页面中始终保持相同的比例?
  2. 这是处理多种分辨率的合适解决方案吗?还是我应该在 CSS 中进行多次 @media 检查并针对每种媒体类型进行多次布局?

html,
body {
height: 100%;
width: 100%;
}

#launchmain {
width: 55%;
display: inline-block;
position: relative;
top: 10%;
left: 25%;
}

#launchmain:after {
padding-top: 79.26%;
display: block;
content: '';
margin-top: 10px;
}

#box1 {
border: 1px solid #000000;
position: absolute;
width: 25.37%;
height: 21.88%
}

#box2 {
border: 1px solid #000000;
width: 48.48%;
height: 21.88%;
position: absolute;
left: 25.64%
}

#box3 {
border: 1px solid #000000;
width: 25.37%;
height: 21.88%;
position: absolute;
left: 74.39%;
}

#box4 {
border: 1px solid #000000;
width: 33.235%;
height: 53.84%;
position: absolute;
top: 22.07%;
}

#maininvite {
border: 1px solid #000000;
width: 33.53%;
height: 53.84%;
position: absolute;
top: 22.07%;
left: 33.235%;
}

#box6 {
border: 1px solid #000000;
width: 33.235%;
height: 53.84%;
position: absolute;
top: 22.07%;
left: 66.765%;
}

#box7 {
border: 1px solid #000000;
width: 25.37%;
height: 21.88%;
position: absolute;
top: 76.2%;
}

#box8 {
border: 1px solid #000000;
width: 48.48%;
height: 21.88%;
position: absolute;
left: 25.64%;
top: 76.2%;
}

#box9 {
border: 1px solid #000000;
width: 25.37%;
height: 21.88%;
position: absolute;
top: 76.2%;
left: 74.39%;
}

#maininvite h2 {
font-size: 180%;
}

p {
position: relative;
font-size: 80%;
}
<div id="launchmain">
<div id="box1"></div>
<div id="box2"></div>
<div id="box3"></div>
<div id="box4"></div>
<div id="maininvite">
<h2> header</h2>
<p>not a lot of text here but still overflowing</p>
</div>
<div id="box6"></div>
<div id="box7"></div>
<div id="box8"></div>
<div id="box9"></div>
</div>

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com