php网页在手机上左右不充满

angryTom
angryTom 原创
2023-02-27 12:08:02 2029浏览

php网页在手机上左右不充满

网页在手机端显示,需要设置一条meta元数据(元数据又称中介数据、中继数据,为描述数据的数据)。这样网页的大小就会适应我们的手机屏幕,在html的head标签内添加:

<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no, minimum-scale=1.0, maximum-scale=1.0"/>

为了让网页在手机端宽度充满屏幕,我们可以设置bodycss样式为

body{
    padding: 0;
    margin: 0;
    width: 100%;
}

另附meta标签其它常用的属性用法解析:

1、<meta name="format-detection"/>

在手机上浏览时,该标签用于指定是否将网页内容中的手机号码显示为拨号的超链接。
在 iPhone 上默认值是:

<meta name="format-detection" content="telephone=yes"/>

如果你不希望手机自动将网页中的电话号码显示为拨号的超链接,那么可以这样写:

<meta name="format-detection" content="telephone=no"/>

2.<meta name="apple-mobile-web-app-capable"/>

<meta name=”apple-mobile-web-app-capable” content=”yes” />

这apple-mobile-web-app-capable的作用就是删除默认的苹果工具栏和菜单栏。content有两个值”yes”和”no”,当我们需要显示工具栏和菜单栏时,这个行meta就不用加了,默认就是显示。

3.<meta name="apple-mobile-web-app-status-bar-style"/>

作用是控制状态栏显示样式:

<meta name=”apple-mobile-web-app-status-bar-style” content=”default” />
<meta name=”apple-mobile-web-app-status-bar-style” content=”black” />
<meta name=”apple-mobile-web-app-status-bar-style” content=”black-translucent” />

default:默认; black:纯黑; black-translucent:半透明灰色

更多PHP相关知识,请访问PHP中文网

以上就是php网页在手机上左右不充满的详细内容,更多请关注php中文网其它相关文章!

声明:本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn核实处理。
上一条:index.php是什么 下一条:php判断是否素数