I created an application, namely UWP in Visual Studio 2015 based on HTML / CSS / JS, which adds 2 to the number that you entered at the touch of a button, and wanted to attach a picture to it as a background. Background set in CSS.

background: url(/images/kartinka.jpg) no-repeat; background-size: 100%; 

But the picture when stretching becomes ugly and I want to make it so that the window can not be stretched.

For example, this happens - when stretching along the "y" axis, the picture does not drag.

But it is necessary to make it so that the window does not stretch at all. enter image description here

This is how the window looks when stretched.

Thanks to those who helped with the organization of the issue.

  • Of course, it is better to always apply the code - gil9red
  • And what exactly is the code? CSS? It just seems to me that the size somewhere is not there to be asked. - ov3rt4ke
  • And where is it, sorry, Visual Studio? - VladD
  • @VladD I do all this in a visual studio, like UWP on JS. - ov3rt4ke
  • one
    @ ov3rt4ke: Ah, this is a UWP! You missed the most important detail. - VladD

1 answer 1

Since UWP applications are universal, it will not work to fix the width and height of the window. You can use the ApplicationView class and set the preferred screen size of an application using PreferredLaunchViewSize

 Windows.UI.ViewManagement.ApplicationView.preferredLaunchViewSize = preferredLaunchViewSize; 

or set the minimum size using

 applicationView.setPreferredMinSize(minSize); 

If I were you, I would still use CSS media and create several variants of the image:

 @media screen and (max-width: 1279px) { background: url(/images/kartinka.jpg) no-repeat; } @media screen and (max-width: 639px) { background: url(/images/kartinkasmall.jpg) no-repeat; }