html - Media query not running for small sizes -


inside panel want set text center align when page sizes < 768, media query not working center text. here fiddle

@@media , (min-width : 768px) {              .text-left {                  text-align: center;              }          }
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>  <link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet"/>  <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>  <nav class="navbar navbar-inverse">    <div class="container-fluid">      <div class="navbar-header">        <button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#mynavbar">          <span class="icon-bar"></span>          <span class="icon-bar"></span>          <span class="icon-bar"></span>        </button>        <a class="navbar-brand" href="#">logo</a>      </div>      <div class="collapse navbar-collapse" id="mynavbar">        <ul class="nav navbar-nav">          <li class="active"><a href="#">home</a></li>          <li><a href="#">messages</a></li>        </ul>        <form class="navbar-form navbar-right" role="search">          <div class="form-group input-group">            <input type="text" class="form-control" placeholder="search..">            <span class="input-group-btn">              <button class="btn btn-default" type="button">                <span class="glyphicon glyphicon-search"></span>              </button>            </span>          </div>        </form>        <ul class="nav navbar-nav navbar-right">          <li><a href="#"><span class="glyphicon glyphicon-user"></span> account</a></li>        </ul>      </div>    </div>  </nav>      <div class="container text-center">    <div class="row">      <div class="col-sm-3 well">        <div class="well">          <p><a href="#">my profile</a></p>          <img src="bird.jpg" class="img-circle" height="65" width="65" alt="avatar">        </div>        <div class="well">          <p><a href="#">interests</a></p>          <p>            <span class="label label-default">news</span>            <span class="label label-primary">w3schools</span>            <span class="label label-success">labels</span>            <span class="label label-info">football</span>            <span class="label label-warning">gaming</span>            <span class="label label-danger">friends</span>          </p>        </div>        <div class="alert alert-success fade in">          <a href="#" class="close" data-dismiss="alert" aria-label="close">×</a>          <p><strong>ey!</strong></p>          people looking @ profile. find out who.        </div>        <p><a href="#">link</a></p>        <p><a href="#">link</a></p>        <p><a href="#">link</a></p>      </div>      <div class="col-sm-7">              <div class="row">          <div class="col-sm-12">            <div class="panel panel-default text-left">              <div class="panel-body">                <p contenteditable="true">status: feeling blue</p>                <button type="button" class="btn btn-default btn-sm">                  <span class="glyphicon glyphicon-thumbs-up"></span>                </button>              </div>            </div>          </div>        </div>                <div class="row">          <div class="col-sm-3">            <div class="well">             <p>john</p>             <img src="bird.jpg" class="img-circle" height="55" width="55" alt="avatar">            </div>          </div>          <div class="col-sm-9">            <div class="well">              <p>just forgot had mention someone how forgot something, forgot it. ahh, forget it! or wait. remember.... no don't.</p>            </div>          </div>        </div>        <div class="row">          <div class="col-sm-3">            <div class="well">             <p>bo</p>             <img src="bandmember.jpg" class="img-circle" height="55" width="55" alt="avatar">            </div>          </div>          <div class="col-sm-9">            <div class="well">              <p>just forgot had mention someone how forgot something, forgot it. ahh, forget it! or wait. remember.... no don't.</p>            </div>          </div>        </div>        <div class="row">          <div class="col-sm-3">            <div class="well">             <p>jane</p>             <img src="bandmember.jpg" class="img-circle" height="55" width="55" alt="avatar">            </div>          </div>          <div class="col-sm-9">            <div class="well">              <p>just forgot had mention someone how forgot something, forgot it. ahh, forget it! or wait. remember.... no don't.</p>            </div>          </div>        </div>        <div class="row">          <div class="col-sm-3">            <div class="well">             <p>anja</p>             <img src="bird.jpg" class="img-circle" height="55" width="55" alt="avatar">            </div>          </div>          <div class="col-sm-9">            <div class="well">              <p>just forgot had mention someone how forgot something, forgot it. ahh, forget it! or wait. remember.... no don't.</p>            </div>          </div>        </div>      </div>      <div class="col-sm-2 well">        <div class="thumbnail">          <p>upcoming events:</p>          <img src="paris.jpg" alt="paris" width="400" height="300">          <p><strong>paris</strong></p>          <p>fri. 27 november 2015</p>          <button class="btn btn-primary">info</button>        </div>        <div class="well">          <p>ads</p>        </div>        <div class="well">          <p>ads</p>        </div>      </div>    </div>  </div>

update! - set media query

@@media screen , (max-width : 767px) {         .text-left {             text-align: center;         }     } 

and when open chrome works fine. if open ie 11 when default window size of around 900px text centered (not good). fyi - if slight window resize text re aligns left! weird ie bug??

for small device can't use min-width.

best way can specifice min , max.

@media , (max-width: ***px) , (min-width: ***px){ } 

more example:

@media screen , (min-width: 768px) {     /* tablets , desktop */ }  @media screen , (max-width: 767px) {     /* phones */ }  @media screen , (max-width: 767px) , (orientation: portrait) {     /* portrait phones */ } 

are worried all , only screen ?

please make scene article link: link_1 link_2

also can read few stackoverflow q this:

question

update answer problem of ie -11

same question on stackoverflow link_1 link_2

solution:

@media , (max-width: ***px) {      //media query css     } 

live_link: link_1 link_2


Comments

Popular posts from this blog

java - SSE Emitter : Manage timeouts and complete() -

jquery - uncaught exception: DataTables Editor - remote hosting of code not allowed -

java - How to resolve error - package com.squareup.okhttp3 doesn't exist? -