前端 - div宽度设置成百分比问题
PHP中文网
PHP中文网 2017-04-17 13:30:18
0
4
713

今天做一个页面时,一个p的width设置成70%,屏幕宽度是1366px,所以这个p宽度是956px左右,这没什么问题。但是当做自适应缩小屏幕时,p的宽度并不是屏幕的70%,这是怎么回事。

PHP中文网
PHP中文网

认证0级讲师

reply all(4)
巴扎黑

I solved it myself. If Google Chrome does not add the meta name="viewport" tag to set it, there will be problems with the scaling ratio, but Firefox has no effect.

Peter_Zhu

The width percentage unit is calculated relative to the width of its parent element. When the parent element of this p is Body, it should be 70% of the browser window width

小葫芦

The screen has shrunk, and the 70% you set will be based on your current width * 70%, instead of the previous 956px

小葫芦

Set width 100% for the parent element

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template