jquery - popup position update based on screen width -



jquery - popup position update based on screen width -

i trying alter position of popup if screen width less 568px through media queries, somehow not working.. here;s code: css:

<style type="text/css"> #wrapper { left: 300px; position: relative; width:500px; } .popup { display:none; width:300px; border:1px solid red; padding: 10px; position: absolute; margin: 10px 0 0 0px; } @media screen , (max-device-width : 568px) { .popup { margin: 10px 0 0 -180px; } } </style>

html:

<div id="wrapper"> <a href="#" class="def">what lorum ipsum?</a> <div class="popup"> lorem ipsum dummy text of printing , typesetting industry. lorem ipsum has been industry's standard dummy text ever since 1500s, when unknown printer took galley of type , scrambled create type specimen book. has survived not 5 centuries, jump electronic typesetting, remaining unchanged. popularised in 1960s release of letraset sheets containing lorem ipsum passages, , more desktop publishing software aldus pagemaker including versions of lorem ipsum. </div> </div> </body> <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script> <script> $(".def").click(function(){ $(".popup").toggle(); }); </script>

here's jsfiddle link: http://jsfiddle.net/0sfve6t3/2/

appreciate feedback/inputs

try jquery:

if($(window).width() < 568){ $('.popup').css('margin','10px 0 0 -180px'); }

try css :

@media screen , (max-width: 567px){ .popup{margin: 10px 0 0 -180px;} }

jquery media-queries

Comments

Popular posts from this blog

c - Compilation of a code: unkown type name string -

java - Bypassing "final local variable defined in an enclosing type" -

json - Hibernate and Jackson (java.lang.IllegalStateException: Cannot call sendError() after the response has been committed) -