【发布时间】:2017-07-10 22:04:54
【问题描述】:
我发现了一篇关于在特定 div 中专门针对移动设备修改文本大小的帖子,如下所示:
@media only screen and (max-width: 480px) {
.news {
font-size: 5px;
}
}
但是对于我正在搞砸的网站,我无法让它工作。我希望在移动设备上打开时字体变小。虽然我想知道我是否必须在 html 中设置一个视口元数据,但每次我这样做 A,它并没有修复它,B,它完全破坏了我的网站的平衡,剪裁了大量的信息,我真的没有不喜欢。所以,我现在能够使用视口的唯一方法是,它是否完全不影响缩放因子。不确定这是否是问题所在。 非常感谢您对此的任何帮助。完整代码:
css:
*{
margin:0;
padding:0;
}
body{
text-align:center; /*For IE6 Shenanigans*/
font-size: 100%;
font-weight: 1;
font-family: 'rationale';
background:black;
}
#newsusa {
position: absolute; /*makes it relative to the html element, (the first
positioned element).*/
width: 100%; /*makes the element 100%, to center it. */
left: 0px;
top: 200px;
}
.news {
color: white;
font-size: 18px;
}
li {
list-style-type: none;
}
@media only screen and (max-width: 480px) {
.news {
font-size: 0.8em;!important;
}
}
@media only screen and (max-width: 280px) {
.news {
font-size: 0.8em;!important;
}
}
xhtml:
<?php include 'global.php';?>
<html xmlns="http://www.w3.org/1999/xhtml">
<html lang="en">
<meta charset="utf-8">
<link rel="stylesheet" type="text/css" href="mobiletest.css">
<link href='//fonts.googleapis.com
/css?family=Iceland|Rationale|Quantico|VT323|Dorsa' rel='stylesheet'
type='text/css'>
<script src='http://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.3
/jquery.min.js'></script>
<div id="newsusa">
<h1 class="appear-later">News</h1>
<div class="spacer1">
</div>
<div class="news">
<ul><?php outputValueFromCache('usnews', 'ignore'); ?></ul>
</div>
<div class="spacer2">
</div>
<h1 class="appear-later">Tech</h1>
<div class="spacer1">
</div>
<div class="news">
<ul><?php outputValueFromCache('usatechnews', 'ignore'); ?></ul>
</div>
<div class="spacer2">
</div>
<h1>Business</h1>
<div class="spacer1">
</div>
<div class="news">
<ul><?php outputValueFromCache('usamoneynews', 'ignore'); ?></ul>
</div>
</div>
</html>
【问题讨论】:
-
尝试使用
font-size: 5px;!important并使用em就像font-size: 0.8em;!important一样