css - 桌面WEB应用自适应问题
PHP中文网
PHP中文网 2017-05-02 09:29:40
0
4
674

盆友在开发一个桌面GUI应用,使用的是NW.js。由于需求方需哟的页面要求自定义比较多,大量使用提供的图片作为dom元件背景,当时的大小和布局都是写死的。现在需要做桌面上的自适应(不要求适应手机端,就几种桌面分辨率),但是由于很多页面的各个部分都是用背景来展示的(就一个p元素设置好大小然后设置背景图片),很难快速方便地改成自适应,想问一下大家有什么好的办法吗?

PHP中文网
PHP中文网

认证高级PHP讲师

reply all(4)
为情所困

You can use percentage for width, vw (Viewport Width) for height, and background image background-size: 100% 100%;.

For example, if you want to implement a responsive square, it might look like this:

.square {
    width: 30%;
    height: 30vw;
    background: url("bg.png") no-repeat scroll center 0 transparent;
    background-size: 100% 100%;
}
大家讲道理

If this is the case, can it be implemented using transform:scale(multiple); on the entire page? (Of course, this requires you to have almost the entire page as background)

为情所困

How about the width percentage? Have you tried replacing the fixed width in batches? Just consider the ratio of container and element widths in fixed resolutions

左手右手慢动作

Like @eechen above, if you use the chrome core browser, you can use the background-size method of CSS3; all element sizes can be scalable and specified such as 50%;

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!