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