M
M
Maxim2015-10-28 16:56:52
JavaScript
Maxim, 2015-10-28 16:56:52

How to hide the map?

Uses Smarty templating engine,
There is a block

<div class="show_map">{include file='map.tpl'}</div>

How to make this block displayed only when the screen width is <640 , the
condition is
if (document.body.clientWidth >640) {
not possible to display the block itself

Answer the question

In order to leave comments, you need to log in

5 answer(s)
D
Danila Avdoshin, 2015-10-28
@avdoshin

Through CSS.

@media only screen and (max-width: 640px) {
    .show_map {
        display: none;
    }
}

A
Alexander Taratin, 2015-10-28
@Taraflex

We wrap the map in an iframe and load it only on wide screens, or if the browser is stretched to a sufficient width. When narrowing the screen, we simply make the map display:none;
These manipulations are quite easy to implement in js.

I
Ivan Solomennikov, 2015-10-28
@ivsol

I would personally use @media screen, if using *js, then you need the , object property window, window.innerWidthwhich is responsible for the width of the browser window, not the page element.

G
GreatRash, 2015-10-28
@GreatRash

document.addEventListener('DOMContentLoaded', function(event) {
  var elem = null;

  if (window.matchMedia("(min-width: 640px)").matches) {
    elem = document.querySelector('div.show_map');
    elem.parentNode.removeChild(elem);
  }
});

I
Ivanq, 2015-10-28
@Ivanq

@media screen and (max-width: 640px) {
    .show_map {
        display: none;
    }
}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question