Som*_*omk 148 css responsive-design twitter-bootstrap
我正在尝试使用bootstrap构建响应式布局,目前正在使用font-size定义一些标题:3em;
但是当布局缩小时,这太大了.我如何能够相应地减小文本的大小?
aWe*_*per 138
最简单的方法是使用%或em中的维度.只需更改基本字体大小,一切都会改变.
减
@media (max-width: @screen-xs) {
body{font-size: 10px;}
}
@media (max-width: @screen-sm) {
body{font-size: 14px;}
}
h5{
font-size: 1.4em;
}
Run Code Online (Sandbox Code Playgroud)
请访问/sf/answers/1538730161/查看所有方法
您可以使用视口单元(vh,vw ...),但它们不适用于Android <4.4
Mur*_*ain 52
好吧,我的解决方案有点破解,但它有效,我正在使用它.
1vw = 1% of viewport width
1vh = 1% of viewport height
1vmin = 1vw or 1vh, whichever is smaller
1vmax = 1vw or 1vh, whichever is larger
h1 {
font-size: 5.9vw;
}
h2 {
font-size: 3.0vh;
}
p {
font-size: 2vmin;
}
Run Code Online (Sandbox Code Playgroud)