惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

S
Securelist
C
CERT Recently Published Vulnerability Notes
Forbes - Security
Forbes - Security
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
L
LINUX DO - 最新话题
The Hacker News
The Hacker News
Google Online Security Blog
Google Online Security Blog
SecWiki News
SecWiki News
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO
The Last Watchdog
The Last Watchdog
S
Schneier on Security
T
Troy Hunt's Blog
N
News | PayPal Newsroom
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
Schneier on Security
Schneier on Security
P
Privacy & Cybersecurity Law Blog
T
Tor Project blog
T
Threatpost
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
A
Arctic Wolf
S
Secure Thoughts
P
Proofpoint News Feed
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
Security Latest
Security Latest
Scott Helme
Scott Helme
Security Archives - TechRepublic
Security Archives - TechRepublic
Latest news
Latest news
PCI Perspectives
PCI Perspectives
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
Hacker News - Newest:
Hacker News - Newest: "LLM"
L
LINUX DO - 热门话题
P
Palo Alto Networks Blog
www.infosecurity-magazine.com
www.infosecurity-magazine.com
G
GRAHAM CLULEY
V2EX - 技术
V2EX - 技术
Google DeepMind News
Google DeepMind News
Project Zero
Project Zero
V
Vulnerabilities – Threatpost
T
Threat Research - Cisco Blogs
Webroot Blog
Webroot Blog
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
N
News and Events Feed by Topic
TaoSecurity Blog
TaoSecurity Blog
大猫的无限游戏
大猫的无限游戏
T
Tenable Blog
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
V
Visual Studio Blog
H
Hacker News: Front Page
Simon Willison's Weblog
Simon Willison's Weblog
AWS News Blog
AWS News Blog

Ahmad Shadeed

Better fluid sizing with round() Use Cases for Field Sizing The Basics of Anchor Positioning Item Flow CSS Relative Colors Balancing Text In CSS Should masonry be part of CSS grid? CSS display contents CSS Grid Areas CSS Cap Unit An Interactive Guide to CSS Container Queries CSS :has() Interactive Guide CSS Nesting UX in DevTools CSS Nesting Future CSS: State Container Queries Rebuilding a comment component with modern CSS Conditional CSS with :has and :nth-last-child CSS Text balancing with text-wrap:balance CSS Masking Do we need CSS flex-wrap detection? My CSS Wishlist Conditional CSS CSS Style Queries Inside the mind of a frontend developer: Article layout Inside the mind of a frontend developer: Hero section CSS container queries are finally here The CSS behind Figma First Look At The CSS object-view-box Property Learn CSS Subgrid CSS :has Parent Selector Aligning Content In Different Wrappers Flexbox Dynamic Line Separator Hello, CSS Cascade Layers Building UI Components With SVG and CSS A Deep CSS Dive Into Radial And Conic Gradients Defensive CSS Building Real-life Components: Facebook Messenger Conditional Border Radius In CSS CSS Container Query Units Aligning a Button Label Vertically Comparing Design Mockups To Code Result Using HSL Colors In CSS Custom Scrollbars In CSS Let CSS Container Queries For Designers The State of CSS Cross-Browser Development Overflow Issues In CSS Inspect Element As A Way To Increase Your Curiosity Handling Text Over Images in CSS Digging Into CSS Logical Properties Clipping Scrollable Areas On The inline-start Side Understanding Clip Path in CSS The Art of Building Real-life Components Handling Short And Long Content In CSS CSS Scroll Snap A Deep Dive Into CSS Grid minmax() CSS Variables 101 Finding The Root Cause of a CSS Bug Learn CSS centering How to detect browser support for Flexbox Gap CSS Mistakes While On Autopilot Digging Into the Flex Property Understanding CSS Multiple Backgrounds Aligning Logo Images in CSS Grid for layout, Flexbox for components Colors in CSS Thinking About The In-between Design Cases min(), max(), and clamp() CSS Functions Image Techniques On The Web Everything About Auto in CSS Learn Box Alignment Let Learn CSS Positioning Intrinsic Sizing In CSS CSS Grid Template Areas In Action Hiding Elements On The Web Creating a Variable Color Font From Scratch Building a Football Ticket With CSS and SVG Blending Modes in CSS CSS Variables With Inline Styles Implementing Dark Mode For My Website Rebuilding Apple Music Header in HTML & CSS Accessible Checkbox Layout Flickering On Browser Resize Enhancing The Clickable Area Size Custom Underlines with SVG Part 3: The Process of Implementing A UI Design From Scratch Part 2: The Process of Implementing A UI Design From Scratch Building An Old Nav Design CSS Flexbox: 5 Real World Use Cases I Used CSS Inline Flex For The First Time The Process of Implementing A UI Design From Scratch Common CSS Issues For Front-End Projects Handling Long and Unexpected Content in CSS How to Build Web Form Layouts With CSS Grid Grid Layout Ah-ha Moment Enhancing Our Components with CSS :empty Building Resizeable Components with Relative CSS Units CSS Writing Mode The Journey of Learning Front End Web Development on a Daily Basis
Use Cases For CSS Vertical Media Queries
Ahmad Shadeed · 2016-04-28 · via Ahmad Shadeed

The Layout Maestro

I spent years teaching CSS layout on this blog. I put everything I know into The Layout Maestro course: 70+ lessons and 150+ interactive examples that teach you how to think CSS layouts, not just memorize syntax.

Get the course

Two weeks ago, Sara Soueidan tweeted about the love of CSS Vertical Media Queries, I’ve remembered that I used them in some projects and so I decided to write an article about them.

We all love media queries, don’t we? Without them our layouts won’t be responsive. Media queries that check for min-width and max-width are well-known and used a lot. In this article we will explore different use cases for using vertical media queries in CSS. So we will focus on min-height and max-height.

1. Sectioning Content

Sometimes the designer work on a web page that is divided into multiple sections, each one should occupy the full viewport height. In CSS, the easiest way to do it is by using viewport unites vh, vw, vmin, vmax. If each section has a content that almost fill it, in smaller viewport height this will cause an overlapping issue so we will notice that each section content appear above the other.

The solution is that we apply the height: 100vh only if the height is bigger than a specified value, test your design and when you notice that something is broken, add a breakpoint.

Demo

See the Pen Sectioning Content by Ahmad Shadeed (@shadeed) on CodePen.

Now the section default height will be determined by the content inside it and if the viewport height is bigger than 400px and width is > 500px, the section height will be 100vh (100% of the viewport).

Fixed headers are a trend and requested from clients a lot these days. I personally don’t like them because they occupy from the screen estate, specially if the height was a bit big. In smaller viewport screens, like for example a mobile landscape mode, why not making the header fixed? We can make it like so only after a certain height so we will be sure that the it doesn’t occupy a lot from the screen estate.

Demo

See the Pen Fixed Header by Ahmad Shadeed (@shadeed) on CodePen.

When you have a fixed footer in your design and you want it to be fixed while scrolling, you might face an issue when the viewport height is not big enough, the hero section content will overlap with the footer and the user won’t be able to read the text. So for that, we will apply the fixed thing for the bar only when the viewport height is good.

Demo

See the Pen Fixed Footer by Ahmad Shadeed (@shadeed) on CodePen.

4. Modals

Usually the modal (dialog) should be centered vertically and horizontally. The goal of this is to grab the user attention. But, in smaller viewport screens the modal top and bottom edges might be very close to the screen vertical edges. In that case, it’s better to make the modal centered horizontally only and for the vertical centering, it will stick to top (no centering).

Demo

See the Pen Modals by Ahmad Shadeed (@shadeed) on CodePen.

There are a lot of patterns for mobile navigation. One of them that cover the whole screen as in the below illustration. In mobile portrait mode it’s almost looking good and the user doesn’t need to scroll down a lot. But in landscape mode, the scrolling will be annoying so the solution for that is to check for height, if it’s less than 400px for example, each navigation item will occupy 50% width.

Demo

See the Pen Mobile Menu by Ahmad Shadeed (@shadeed) on CodePen.

In some cases, it’s useful to switch the header element between being fixed at top and on the side. We can do that by checking for the width and height.

Demo

See the Pen Sidebar Vs. Header by Ahmad Shadeed (@shadeed) on CodePen.

7. Shrinking Font Sizes and Spacing

Simply the idea is to shrink the font sizes and spacing to show more content when the height is not enough. While I don’t recommend to follow this approach 100%, but be sure to use it with care. Test, Test, test…

Bootstrap has a nice example of this, while I was searching about the topic I found a page on CSS Tricks that has an example of this idea.

Demo

The End

It’s the end! Do you have any interesting use cases that you would like to share with me? I will be happy to hear from you on Twitter! Ping me on @shadeed9

{% include note.html content = “Some of the above use cases and solutions are examples of issues I faced while working on real projects. That said, they might not work for your case so please pick them wisely and carefully.” %}

Further reading:

{% include share.html text = “Use Cases For CSS Vertical Media Queries” link = “https://ishadeed.com/article/vertical-media-queries/” %}

Thank you for reading, you are AWESOME <3