Hidehide Elements At Different Window Sizes



The 'size' of the screen is related to pixels not physical size. The external lower resolution TV has fewer pixels thus depicted smaller. Windows I guess won't know anything about the physical size. #4 that's right as well, again perfect sense to me. What is an 'issue' for some seems quite impressive to me. Scaling down the page to fit on smaller screen sizes will make the content unreadable, but if you scale the content relative to one another and switch to 1 column it makes it much more readable. Example of our logo design page in three different screen sizes for responsive website design. Things to think about —.

CSS Box Sizing

Hide hide elements at different window sizes of one

The CSS box-sizing property allows us to include the padding and border in an element's total width and height.

Without the CSS box-sizing Property

11.1.2 developer image.dmg san francisco tree andy goldsworthy. By default, the width and height of an element is calculated like this:

width + padding + border = actual width of an element
height + padding + border = actual height of an element

This means: When you set the width/height of an element, the element often appears bigger than you have set (because the element's border and padding are added to the element's specified width/height).

The following illustration shows two <div> elements with the same specified width and height:

This div is smaller (width is 300px and height is 100px).

This div is bigger (width is also 300px and height is 100px).

The two <div> elements above end up with different sizes in the result (because div2 has a padding specified):

Example

.div1 {
width: 300px;
height: 100px;
border: 1px solid blue;
}
.div2 {
width: 300px;
height: 100px;
padding: 50px;
border: 1px solid red;
}
Try it Yourself »

The box-sizing property solves this problem.

Hide hide elements at different window sizes chart

With the CSS box-sizing Property

The box-sizing property allows us to include the padding and border in an element's total width and height.

If you set box-sizing: border-box; on an element, padding and border are included in the width and height:

Both divs are the same size now!

Here is the same example as above, with box-sizing: border-box; added to both <div> elements:

Example

.div1 {
width: 300px;
height: 100px;
border: 1px solid blue;
box-sizing: border-box;
}
.div2 {
width: 300px;
height: 100px;
padding: 50px;
border: 1px solid red;
box-sizing: border-box;
}
Try it Yourself »

Since the result of using the box-sizing: border-box; is so much better, many developers want all elements on their pages to work this way.

The code below ensures that all elements are sized in this more intuitive way. Many browsers already use box-sizing: border-box; for many form elements (but not all - which is why inputs and text areas look different at width: 100%;).

Applying this to all elements is safe and wise:

Example

Try it Yourself »

CSS Box Sizing Property

PropertyDescription
box-sizingDefines how the width and height of an element are calculated: should they include padding and borders, or not

-->

UWP apps use effective pixels to guarantee that your UI will be legible and usable on all Windows-powered devices. So, why would you ever want to customize your app's UI for a specific device family?

  • To make the most effective use of space and reduce the need to navigate

    If you design an app to look good on a device that has a small screen, such as a tablet, the app will be usable on a PC with a much bigger display, but there will probably be some wasted space. You can customize the app to display more content when the screen is above a certain size. For example, a shopping app might display one merchandise category at a time on a tablet, but show multiple categories and products simultaneously on a PC or laptop.

    By putting more content on the screen, you reduce the amount of navigation that the user needs to perform.

  • To take advantage of devices' capabilities

    Certain devices are more likely to have certain device capabilities. Mac brushmac makeup brushes. For example, laptops are likely to have a location sensor and a camera, while a TV might not have either. Your app can detect which capabilities are available and enable features that use them.

  • To optimize for input

    The universal control library works with all input types (touch, pen, keyboard, mouse), but you can still optimize for certain input types by re-arranging your UI elements. For example, if you place navigation elements at the bottom of the screen, they'll be easier for phone users to access—but most PC users expect to see navigation elements toward the top of the screen.

When you optimize your app's UI for specific screen widths, we say that you're creating a responsive design. Here are six responsive design techniques you can use to customize your app's UI.

Tip

Many UWP controls automatically implement these responsive behaviors. To create a responsive UI, we recommend checking out the UWP controls.

Reposition

You can alter the location and position of UI elements to make the most of the window size. In this example, the smaller window stacks elements vertically. When the app translates to a larger window, elements can take advantage of the wider window width.

In this example design for a photo app, the photo app repositions its content on larger screens.

Resize

You can optimize for the window size by adjusting the margins and size of UI elements. For example, this could augment the reading experience on a larger screen by simply growing the content frame.

Hide Hide Elements At Different Window Sizes Of One

Reflow

Hide hide elements at different window sizes chart

By changing the flow of UI elements based on device and orientation, your app can offer an optimal display of content. For instance, when going to a larger screen, it might make sense to add columns, use larger containers, or generate list items in a different way.

This example shows how a single column of vertically scrolling content on a smaller screen that can be reflowed on a larger screen to display two columns of text.

Hide Hide Elements At Different Window Sizes Larger

Show/hide

You can show or hide UI elements based on screen real estate, or when the device supports additional functionality, specific situations, or preferred screen orientations.

For example, media player controls reduce the button set on smaller screens and expand on larger screens. The media player on a larger window can handle far more on-screen functionality than it can on a smaller window.

Part of the reveal-or-hide technique includes choosing when to display more metadata. With smaller windows, it's best to show a minimal amount of metadata. With larger windows, a significant amount of metadata can be surfaced. Some examples of when to show or hide metadata include:

  • In an email app, you can display the user's avatar.
  • In a music app, you can display more info about an album or artist.
  • In a video app, you can display more info about a film or a show, such as showing cast and crew details.
  • In any app, you can break apart columns and reveal more details.
  • In any app, you can take something that's vertically stacked and lay it out horizontally. When going from phone or phablet to larger devices, stacked list items can change to reveal rows of list items and columns of metadata.

Replace

This technique lets you switch the user interface for a specific breakpoints. In this example, the nav pane and its compact, transient UI works well for a smaller screen, but on a larger screen, tabs might be a better choice.

Hide Hide Elements At Different Window Sizes Chart

The NavigationView control supports this responsive technique, by letting users set the pane position to either top or left.

Re-architect

Hide Hide Elements At Different Window Sizes For A

You can collapse or fork the architecture of your app to better target specific devices. In this example, expanding the window shows the entire master/details pattern.

Related topics