Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Devices won't scale for responsive #7

Open
vertis opened this issue Nov 10, 2018 · 9 comments
Open

Devices won't scale for responsive #7

vertis opened this issue Nov 10, 2018 · 9 comments

Comments

@vertis
Copy link

vertis commented Nov 10, 2018

I've spent a bunch of time trying to get these devices to scale when displayed on a mobile screen and can't seem to get them to work correctly. Using something like transform shrinks the device but also screws up any alignment and puts it off the page.

@makeitTim
Copy link

Hey yeah, I was just trying that. Transform is a mess here.

I think the correct approach would be re-doing all the units. Easiest would be to use rem units relative to the html font-size, and then set the html font-size to vw or vh and/or using @media breakpoints to fit your responsiveness. The problem with that is playing nice with the rest of the units on the page.

The same idea would have be done with em but the nested element structure would make that complicated to convert to.

@kovic
Copy link

kovic commented May 23, 2019

i think one option is, rewrite in the html the css .device{ transform: scale(1); } in every mediaquery, with this the device resize fast and the content resize to, to align the dervice i create a div with other class over, simple put the div alignment

(sorry for my english)

@brunolemos
Copy link

Found this responsive one for iphone x: https://codepen.io/dani3lsz/pen/MEZjeo

Ideally all of them should be responsive :(

@khasky
Copy link

khasky commented Aug 8, 2019

+1,
Absolutely useless without responsive mode.

@JeanHules
Copy link

css zoom seems to be a quick and easy temporary fix.

@iMerica
Copy link

iMerica commented Mar 15, 2020

css zoom will only work in Chrome. For cross-browser, you need to use transform: scale(), however this will also require some work to account for the padding.

@rvilgalys
Copy link

Ran into this issue myself and this works pretty well if you just need responsive sizes:

.device {
  position: relative;
  transform: scale(1);
  transform-origin: 50% 0%;
  z-index: 1;
}

@media only screen and (max-width: 1024px) {
  .device {
    transform: scale(0.75);
  }
}

@media only screen and (max-width: 768px) {
  .device {
    transform: scale(0.66);
  }
}

@media only screen and (max-width: 640px) {
  .device {
    transform: scale(0.5);
  }
}

@JiangWeixian
Copy link

Currently I forked the source css file from package devices.css, use a tricky way to add --devices-scale to .device. And replace each px value to calc(var(--devices-scale)*${p1}), e.g.

.device {
  --devices-scale: 1;
}

.device-iphone-14-pro .device-frame {
  background: #010101;
  border: calc(var(--devices-scale)*1px) solid #1b1721;
  border-radius: calc(var(--devices-scale)*68px);
  box-shadow: inset 0 0 calc(var(--devices-scale)*4px) calc(var(--devices-scale)*2px) #c0b7cd, inset 0 0 0 calc(var(--devices-scale)*6px) #342c3f;
  height: calc(var(--devices-scale)*868px);
  padding: calc(var(--devices-scale)*19px);
  width: calc(var(--devices-scale)*428px);
}

In this way, device will not spend original size. Already open pr here #18

@configtheworld
Copy link

Currently I forked the source css file from package devices.css, use a tricky way to add --devices-scale to .device. And replace each px value to calc(var(--devices-scale)*${p1}), e.g.

.device {
  --devices-scale: 1;
}

.device-iphone-14-pro .device-frame {
  background: #010101;
  border: calc(var(--devices-scale)*1px) solid #1b1721;
  border-radius: calc(var(--devices-scale)*68px);
  box-shadow: inset 0 0 calc(var(--devices-scale)*4px) calc(var(--devices-scale)*2px) #c0b7cd, inset 0 0 0 calc(var(--devices-scale)*6px) #342c3f;
  height: calc(var(--devices-scale)*868px);
  padding: calc(var(--devices-scale)*19px);
  width: calc(var(--devices-scale)*428px);
}

In this way, device will not spend original size. Already open pr here #18

Thanks @JiangWeixian , I do not know using that much of calc will effect as less performance while page loading or not but after replacing the all px elements with calc(var(--devices-scale)*${p1}), basically I created lg md sm xs classes and worked perfectly.

.device {
  position: relative;
  transform: scale(1);
  z-index: 1;
}
.device-lg {
  --devices-scale: 1;
}
.device-md {
  --devices-scale: 0.6;
}
.device-sm {
  --devices-scale: 0.4;
}
.device-xs {
  --devices-scale: 0.2;
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

11 participants