Показать сообщение отдельно
  #2 (permalink)  
Старый 17.03.2020, 19:05
Аватар для voraa
Профессор
Отправить личное сообщение для voraa Посмотреть профиль Найти все сообщения от voraa
 
Регистрация: 03.02.2020
Сообщений: 2,712

Проверил у себя на мобильном
Вот такой код
<!doctype html>
<html>
<head>
  <meta http-equiv="Content-type" content="text/html; charset=utf-8" lang="ru">
  <meta name="viewport" content="width=device-width">
<style>
.d1
{
    width:400px;
    height:100px;
    background-color:green;
    color:white;
    font-size:xx-large;
}
 
.d2
{
    display:inline;
}
 
.d3
{
    display: none;
}
 
@media (max-width: 596px) {
.d2
{
    display: none;
}
 
.d3
{
    display: inline;
}
}
</style>
<script>
viewport = document.querySelector("meta[name=viewport]");
viewport.setAttribute('content', 'width=597');
</script>
</head> 
<body> 
<div class="d1">
<span class="d2">
ПК <script>
document.write(document.querySelector("meta[name=viewport]").getAttribute('content')+' '+screen.width);
</script>
</span>
<span class="d3"
>Моб <script>
document.write(document.querySelector("meta[name=viewport]").getAttribute('content')+' '+screen.width);
</script>
</span>
</div>
</body>
</html>


Выдает
ПК width=597 360
И в Хроме и в Файрфоксе в портретном режиме
Ответить с цитированием