2017-01-16 29 views
-1

我想为网站制作标题,并且我使用的字体大小在达到一定宽度时需要更改。当你用不同的宽度加载页面时,他们会加载正确的字体,但是当你改变视口大小时,他们不会改变字体。不改变字体大小的媒体查询

<!DOCTYPE html> 
<html lang="en"> 
<head> 
    <meta charset="utf-8"> 
    <link rel="stylesheet" type="text/css" href="style.css"> 
    <meta name="viewport" content="width=device-width, initial-scale=1"> 
    <title>Example</title> 
    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css"> 
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script> 
    <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script> 
    <script type="text/javascript" src="assets/js/results.js"></script> 
</head> 
<body> 
<div class="header"> 
<img src="Logo_whiteTextandCar_exactsize.png" alt="Baja Logo"> 
<div id="main_header"> 
     <span>ABOUT</span> 
     <span>TEAM</span> 
     <span>RESULTS</span> 
     <span>GALLERY</span> 
     <span>SPONSORS &amp; DONATE</span> 
    </div> 
</div> 

而且style.css中:

@media screen and (max-width: 980px){ 
    .header{ 
     font-size: 12pt; 
    } 
} 
+1

[我不能重现该问题(HTTP:// jsbin .com/loxili/1/edit?html,output)[mcve] – Quentin

+2

这是你的真实代码吗?我的意思是,你的CSS就像HTML一样吗? –

+0

不,它是在style.css文件 – bill

回答

-2

嵌入式CSS样式必须标记之间写:<style></style>

<!DOCTYPE html> 
<html lang="en"> 
<head> 
    <meta charset="utf-8"> 
    <link rel="stylesheet" type="text/css" href="style.css"> 
    <meta name="viewport" content="width=device-width, initial-scale=1"> 
    <title>Example</title> 
    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css"> 
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script> 
    <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script> 
    <script type="text/javascript" src="assets/js/results.js"></script> 

    <style> 
     @media screen and (max-width: 980px){ 
     .header{ 
      font-size: 12pt; 
     } 
     } 
    </style> 

</head> 
<body> 
<div class="header"> 
<img src="Logo_whiteTextandCar_exactsize.png" alt="Baja Logo"> 
<div id="main_header"> 
     <span>ABOUT</span> 
     <span>TEAM</span> 
     <span>RESULTS</span> 
     <span>GALLERY</span> 
     <span>SPONSORS &amp; DONATE</span> 
    </div> 
</div> 
</body> 
</html> 
+0

它在外部文件风格.css我只是在这里格式错误 – bill