前端 - 请问手机端的背景与固定二维码的响应式应该怎么写
天蓬老师
天蓬老师 2017-04-17 11:32:55
0
2
536

类似于这种,二维码是后期程序自动生成,在手机上要全屏,我是将背景放在img标签里,宽度100%,让容器的高度和图片高度一样,然后二维码绝对定位根据背景大小确定宽高和定位,可每次计算都好麻烦,这种应该怎么做。

天蓬老师
天蓬老师

欢迎选择我的课程,让我们一起见证您的进步~~

reply all(2)
刘奇

Set the background to 100% for display. You can calculate the width of the QR code and 640px based on a fixed value such as margin-top, and finally convert it into the corresponding percentage and center the image.

黄舟

You can use the background's background-cover to set the background. As for the centering of the QR code, I don't know whether it is centered left and right at a certain position or centered on the entire screen. If it is centered left and right at a certain height, you can use absolute positioning and set Set the value of bottom, and then set left:50%; plus margin-left:宽度/2px; to achieve left and right centering.
If the entire screen is centered, the left and right still follow the above method, and the top and bottom centering can also be achieved according to the left and right centering method.

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