媒体查询仅影响Index.html中的元素/类,而不影响其他路径中的元素/类

时间:2017-01-11 02:27:24

标签: html css routes media-queries meta-tags

所以我试图让我的网站具有移动响应能力,因为我有它想要它在桌面上看的方式。但是,我的媒体查询不适用于index.html以外的任何其他视图中的类,我无法弄清楚原因。

的index.html:

html ng-app ='skypeClone'

`

  <head>
    <meta charset="utf-8">
    <!-- <meta name="viewport" content="width=device-width, initial-scale=1.0"/> Have tried media queries with and without this-->
    <link rel="stylesheet" type="text/css" href="styles.css">
    <title>Skype Clone</title>
  </head>
  <body ng-controller='mainCtrl'>

<ui-view class="view"></ui-view>

<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.4.9/angular.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/angular-ui-router/0.2.18/angular-ui-router.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.js"></script>
<script src="//cdn.temasys.com.sg/skylink/skylinkjs/0.6.x/skylink.complete.min.js"></script>
<script src="js/app.js"></script>
<script src="js/mainCtrl.js"></script>
<script src="js/helpCtrl.js"></script>
<script src="js/loginCtrl.js"></script>
<script src="js/loginSvc.js"></script>
<script src="js/createUserCtrl.js"></script>
<script src="js/createUserSvc.js"></script>
<script src="js/service.js"></script>
<script src="js/userHomeCtrl.js"></script>
</body
</html>

` 如果注释掉的代码没有显示,我尝试使用和不使用meta name =“viewport”content =“width = device-width,initial-scale = 1.0”的媒体查询

其他路线:

`

<div id="background-setter-homepage">
  <div id="header-wrap">
    <div id="header">
        <button class="button" id="help" ui-sref='help'>Help</button>
        <button class="button" id="about" ui-sref='about'>About</button>
        <button class="button" id="login" ui-sref='login'>Login</button>
    </div>
  </div>
     <br><br>
    <div class="middleOfPage" id="container">
      <div id="text-and-button">
      <h2 id="phrase">Skyclone keeps the world talking, for free</h2> <br>
      <button class="button" id="getStarted" ui-sref='createUser'>Create An Account</button>
      <div>
    </div>

</div>

`

所有我想测试的只是为了使它工作,当屏幕达到某个最大宽度时,让h2元素的类'短语'变为红色。

CSS:

`

@media (max-width: 375px) {
  #phrase{
    color: lightgreen;
  }
}

` 我也试过了

`

@media only screen and (max-width: 800px) {
    #phrase{
       color: lightgreen;
    }
}

` 上面的代码不起作用,但是如果我在index.html中选择ui-view上的类并将可见性设置为相同的宽度,则它将起作用。所以它有点工作......但不是真的。

你们有没有遇到过这个问题?我现在不知所措。任何和所有的帮助是超级赞赏!提前致谢(:

1 个答案:

答案 0 :(得分:1)

如果在同一媒体查询中将可见性设置为无效,则可能只需将color: lightgreen;更改为color: lightgreen !important;

你试过吗?

相关问题