2017-07-10 58 views
0

我发现了一个关于在特定的div专门修改文本大小的移动,这样的修改后的文本字体大小:无法在移动

@media only screen and (max-width: 480px) { 

.news { 
    font-size: 5px; 
} 
} 

我不能得到那个不过,对于现场工作我在搞乱。我希望在移动设备上打开时字体大小更小。虽然我不知道是否必须在html中设置视口meta,但每次我这样做时,它都不能修复它,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> 
+0

尝试使用'font-size:5px;!important'并使用'em'来处理,如'font-size:0.8em;!important' – hansTheFranz

回答

1

你将需要在

<meta name="viewport" content="width=device-width, initial-scale=1">

添加到您的标题。如果您考虑以下代码:

<html> 
    <head> 
     <meta name="viewport" content="width=device-width, initial-scale=1"> 
     <style> 
      .page-header{ 
       font-size: 16px; 
       color: red; 
      } 
      @media (max-width: 430px) { 
       .page-header{ 
        font-size:100px; 
        color: green; 
       } 
      } 
     </style> 
    </head> 
    <body> 
     <h1 class="page-header">Hello</h1> 
    </body> 
</html> 

媒体查询仅在您定义了视口元标记后才起作用。我知道这可能不是你想听到的,但我认为这是你的解决方案。

+0

除媒体查询外。 – Blaise

+0

感谢您的回复。我试过这样做,没有看到有什么区别。不知道我做错了什么。 – daytradeit

+0

Try @media(max-width:768px)。如果你得到这个工作,你将不需要这些重要的进口产品,这将会在路上节省很多麻烦。 – Blaise