Script detecting mobile device
<script> if(/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent)){ document.currentScript.outerHTML = `[img=images/mapka_apartmany.jpeg scale=5% float=right]`; }else{ document.currentScript.outerHTML = `[img=images/mapka_apartmany.jpeg scale=18% float=right]`; } </script>
CSS: change the background color when the browser window is less 400px
@media only screen and (max-width: 400px) { body { background-color: lightblue; } }
Codepen: https://codepen.io/L … r-Ludvik/pen/RNbjeOV
More example: https://www.w3school … ref/atrule_media.php
This script also detecting mobile device:
<script> if (window.matchMedia("(max-width: 400px)").matches) { // Viewport is less or equal to 400 pixels on mobile document.currentScript.outerHTML = `less or equal to 400` } else { // Viewport is greater than 400 pixels on desktop document.currentScript.outerHTML = `greater than 400` } document.write("<br>"); document.write(document.documentElement["clientWidth"]); document.write("<br>"); document.write(document.body["scrollWidth"]); </script>