2017-07-10 59 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