![]() We’ve been looking at a demo made for a vertical/portrait design, but works just as well at larger landscape screen sizes, depending on the content we’re working with. What this three-liner does is add a click event handler over the #page element that un-checks the checkbox if the checkbox is in a :checked state, which closes the menu. So, we select the ::after pseudo element of checkbox input when the input is in a :checked state: input:checked::after First, the menu icon changes to an × mark, symbolizing that it can be clicked to close the menu. Two things happen when the menu control is clicked. I threw in the styles for the #page content as well, which is going to be a full size background image. Z-index: 1 /* makes sure it stacks on top */īackground: url("earbuds.jpg") #ebebeb center/cover Width: 30px height: 30px /* sets the menu icon dimensions */ …and the baseline CSS for the Checkbox Hack and menu icon: /* Hide checkbox and reset styles */Īppearance: initial /* removes the square box */īorder: 0 margin: 0 outline: none /* removes default margin, border and outline */ The checkbox’s default style (added by the browser) is stripped out, using the appearance CSS property, before adding its pseudo element with the menu icon so that the user doesn’t see the square of the checkbox. If that’ll cause layout concerns for you, use Grid or Flexbox for your layouts as they are source order independent, like how I used its advantage for counting in CSS. ![]() It’s important the checkbox precedes the main content in the source code, because the :checked selector we’re going to ultimately write to make this work needs to use a sibling selector. Of course, the Checkbox Hack isn’t the only way to do this, and if you want to toggle a class to open and close the menu with JavaScript, that’s absolutely fine. We don’t even need JavaScript to do the lifting! When you tap the icon and the name changes to Auto-rotate, the screen rotation feature is enabled. From the menu, tap the icon that says Auto-rotate or Portrait, as shown in the images below. This action brings up a small menu of icons. Checking the box (or, ahem, the menu icon) reveals the menu. Screen rotation for an Android tablet From the top-right of the screen, swipe down and to the left two times. The checkbox is hidden and placed under the menu icon with CSS, so the user never sees it even though they interact with it. It’s perfect because a checkbox has two common interactive states - checked and unchecked (there’s also the indeterminate) - that can be used to trigger those states. This is where the Checkbox Hack comes into play. We’re building a menu that has two states - open and closed - and it toggles between the two. It has the persistence and availability of a fixed position as well as the space-saving attributes of a hidden menu that flies out, only without removing the user from the current content of the page. A fly-out menu, at best, obscures the content and, at worst, removes it completely from the UI. What I don’t like about them is how often they conflict with the content of the page. But when I’m looking for a menu that is stingy on real estate and easy to access, they’re hard to beat. Frankly, I tend to like fly-out menus in general. Whatever the approach, they all have their pros and cons and the right one depends on the situation where it’s being used. Some fly out and overlap the content, some push the content away, and others will do some sort of full-screen deal. ![]() And there are even additional approaches on how hidden menus reveal their menu items. Other menus are hidden by design and need to be opened to view the options. Some menus are persistent, always in view and display all the options. When you switch to tablet mode by rotating its screen all the way back on a convertible device with a 360-degree hinge, or disconnecting the screen from the keyboard, automatic rotation will be enabled and the Rotate lock setting will be available.ģ When finished, you can close Settings if you like.There are many different approaches to menus on websites. This is because, in standard laptop mode, the screen will never automatically rotate. If you have a device with a removable screen, rotation lock will be grayed out while the screen is connected to keyboard. If you have a convertible (aka: 2in1) PC with a 360-degree hinge, rotation lock will be grayed out when it is in normal laptop mode. If the Rotate lock setting is grayed out, then often you can just rotate your display to be able to turn on or off. You can also right click or press and hold on your desktop, and click/tap on Display settings to open the same page in Settings.Ģ Click/tap on Display on the left side, and turn on or off (default) Rotation lock on the right side for what you want. 1 Open Settings, and click/tap on the System icon.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |