我如何根据屏幕尺寸扩展网站或缩小规模

发布于 2025-02-01 04:13:21 字数 240 浏览 2 评论 0原文

因此,我制作了一个网站,该网站的图像具有多个文本框,等等,一些用户百分比以及有些使用像素,我的意思是他们现在使用它来在特定的位置。因此,如果您将笔记本电脑连接到电视并放置网站,它将自动扩展完美地扩展,这会使事物有些模糊,但一切都已经到位。我想知道如何为我的网站添加一个函数,该函数选择页面中的所有内容,只是根据屏幕尺寸缩小或扩展它,我不在乎它在收缩或扩展后是否会变得模糊。或者,如果有人对我如何使所有内容都适合页面的所有想法,那么无论屏幕尺寸如何,它都会非常有帮助。

so i made a website that has images multiple textboxes and etc, some user percentage and some use pixels by that i mean they use that to be in the specific place there in right now. So if you connect your laptop to a tv and put the website it will automatically scale up perfectly it just causes the things to be a little blurry but everything is in place. i was wondering how i can add like a function for my website that selects everything in the page and just shrinks it or expands it depending on the screen size, i dont care if it gets blurry after shrinking or expanding. Or if anyone has any other idea on how i can make everything fit to page no matter screen size it would be very helpful.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

ㄟ。诗瑗 2025-02-08 04:13:21

首先,有多种方法可以使网站遇到责任心,
最简单的方法是媒体查询:

@media only screen and (max-width: 600px) {
  body {
    background: #fff;
  }
}
@media only screen and (min-width: 601px) {
  body {
    background: #ccc;
  }
}

这也可以应用于不同的样式表:

    <link rel="stylesheet" type="text/css" href="/styles/gardener_main.css" media="screen"/>
    <link rel="stylesheet" type="text/css" href="/styles/additional.css" media="screen"/>
    <link rel="stylesheet" type="text/css" href="/styles/gardener_800.css" media="screen and (min-width: 800px)"/>
    <link rel="stylesheet" type="text/css" href="/styles/gardener_799.css" media="screen and (max-width: 799px)"/>

他们基本上告诉设备用于显示尺寸的样式。

首先,您可以努力:
//www.www.w3schools.coms.coms.comsss/csssss/cssss_rwd_mediaquelies.mediaqueries.asp

https: 更好地理解媒体查询本身。

但!大多数人往往会忘记您还需要调整HTML:

<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1" />

根据您想要支持的设备和旧设备的数量和数量,您还可以添加一个基本替代所有内容的开关:

<?php

    $mobrowser = '0'; 
    if (preg_match('/(up.browser|up.link|mmp|symbian|smartphone|midp|wap|phone|android)/i', 
    strtolower($_SERVER['HTTP_USER_AGENT']))) {
    $mobrowser++;
    }if ((strpos(strtolower($_SERVER['HTTP_ACCEPT']),'application/vnd.wap.xhtml+xml') > 0) or 
    ((isset($_SERVER['HTTP_X_WAP_PROFILE']) 
    or isset($_SERVER['HTTP_PROFILE'])))) {$mobile_browser++;}
    $mobile_ua = strtolower(substr($_SERVER['HTTP_USER_AGENT'], 0, 4));
    $mobile_agents = array(
    'w3c ','acs-','alav','alca','amoi','audi','avan','benq','bird','blac',
    'blaz','brew','cell','cldc','cmd-','dang','doco','eric','hipt','inno',
    'ipaq','java','jigs','kddi','keji','leno','lg-c','lg-d','lg-g','lge-',
    'maui','maxo','midp','mits','mmef','mobi','mot-','moto','mwbp','nec-',
    'newt','noki','oper','palm','pana','pant','phil','play','port','prox',
    'qwap','sage','sams','sany','sch-','sec-','send','seri','sgh-','shar',
    'sie-','siem','smal','smar','sony','sph-','symb','t-mo','teli','tim-',
    'tosh','tsm-','upg1','upsi','vk-v','voda','wap-','wapa','wapi','wapp',
    'wapr','webc','winw','winw','xda ','xda-');
    
    if (in_array($mobile_ua,$mobile_agents)) {$mobrowser++;}
    if (strpos(strtolower($_SERVER['ALL_HTTP']),'OperaMini') > 0) {$mobrowser++;}
    if (strpos(strtolower($_SERVER['HTTP_USER_AGENT']),'windows') > 0) {$mobrowser = 0;}
    if ($mobrowser > 0) {
    echo '
    HTML old mobile devices etc
    ';
    }
    else {
    echo '
    HTML desktop
    ';
    }?>

使用此ENMUS,您可以抓住移动设备,
但是,只有当您真的想支持时,这些事情才会很有趣
历史设备。

First of all, there are multiple ways to make a site responsiv,
the easiest way are the media queries:

@media only screen and (max-width: 600px) {
  body {
    background: #fff;
  }
}
@media only screen and (min-width: 601px) {
  body {
    background: #ccc;
  }
}

This can also be applied to different stylesheets:

    <link rel="stylesheet" type="text/css" href="/styles/gardener_main.css" media="screen"/>
    <link rel="stylesheet" type="text/css" href="/styles/additional.css" media="screen"/>
    <link rel="stylesheet" type="text/css" href="/styles/gardener_800.css" media="screen and (min-width: 800px)"/>
    <link rel="stylesheet" type="text/css" href="/styles/gardener_799.css" media="screen and (max-width: 799px)"/>

They are basicly telling the devices what styles to use for what display size.

For the start you can work through this:
https://www.w3schools.com/css/css_rwd_mediaqueries.asp

to get a better understanding of the media query itself.

But! Most somehow tend to forget that you also need to adjust your html:

<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1" />

Depending on how much devices and how much older devices you want to support you can also add a switch that basicly replaces everything:

<?php

    $mobrowser = '0'; 
    if (preg_match('/(up.browser|up.link|mmp|symbian|smartphone|midp|wap|phone|android)/i', 
    strtolower($_SERVER['HTTP_USER_AGENT']))) {
    $mobrowser++;
    }if ((strpos(strtolower($_SERVER['HTTP_ACCEPT']),'application/vnd.wap.xhtml+xml') > 0) or 
    ((isset($_SERVER['HTTP_X_WAP_PROFILE']) 
    or isset($_SERVER['HTTP_PROFILE'])))) {$mobile_browser++;}
    $mobile_ua = strtolower(substr($_SERVER['HTTP_USER_AGENT'], 0, 4));
    $mobile_agents = array(
    'w3c ','acs-','alav','alca','amoi','audi','avan','benq','bird','blac',
    'blaz','brew','cell','cldc','cmd-','dang','doco','eric','hipt','inno',
    'ipaq','java','jigs','kddi','keji','leno','lg-c','lg-d','lg-g','lge-',
    'maui','maxo','midp','mits','mmef','mobi','mot-','moto','mwbp','nec-',
    'newt','noki','oper','palm','pana','pant','phil','play','port','prox',
    'qwap','sage','sams','sany','sch-','sec-','send','seri','sgh-','shar',
    'sie-','siem','smal','smar','sony','sph-','symb','t-mo','teli','tim-',
    'tosh','tsm-','upg1','upsi','vk-v','voda','wap-','wapa','wapi','wapp',
    'wapr','webc','winw','winw','xda ','xda-');
    
    if (in_array($mobile_ua,$mobile_agents)) {$mobrowser++;}
    if (strpos(strtolower($_SERVER['ALL_HTTP']),'OperaMini') > 0) {$mobrowser++;}
    if (strpos(strtolower($_SERVER['HTTP_USER_AGENT']),'windows') > 0) {$mobrowser = 0;}
    if ($mobrowser > 0) {
    echo '
    HTML old mobile devices etc
    ';
    }
    else {
    echo '
    HTML desktop
    ';
    }?>

With this enormus something you can grab the mobile agents,
but such things are only interesting if you really want to support
historic devices.

痴情 2025-02-08 04:13:21

也许您可以尝试添加一些CSS
@Media屏幕和(最小宽度:1240px){...}

Maybe you could try to add some css like
@media screen and (min-width: 1240px) {...}

自由如风 2025-02-08 04:13:21

响应能力

这是您可以测试它的方法。只需在浏览器中打开它,请右键单击“检查元素”或F12。我用红色标记,您可以看到它的外观在不同的尺寸上。

Responsive

Here is how you can test it. Just open it in browser, go right click inspect element or f12. I marked with red where you can see that, how it will look on different sizes.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文