Giter VIP home page Giter VIP logo

cq-demos's Introduction

Container Query demos

As yet unproposed, the Container Queries CSS Module allows developers to style elements based on their size and shape. This repo is intended to allow developers to experiment with “container queries” and, in doing so, help find potential issues that might arise when writing the proposed specification.

This repo uses a modified version of Rob Brackett’s element-query script.

Adding a Demo

  1. Copy the demo-template directory to /demos
  2. Rename the directory to whatever you’d like to name your demo, or just a numbered demoX.
  3. Follow the “Quick Setup” instructions below.
  4. Build a demo using any combination of .el:media(min-width){} and/or .el:media(max-width){} syntax. This can be as simple or as complex as you like; anything from changing a background color on an element to an entire page layout.
  5. Update the “Existing Demos” section of the README below with a link to your demo and a brief description.
  6. Send us a PR, and we’ll add your demo to the collection here.
  7. File an issue if you have any feedback at all—whether you ran into any problems using this pattern, have any suggestions for the syntax itself, or just want to share your thoughts on using it.

Existing Demos

Whitworth
Illustrates how container queries could be used for both modular layout, and finessing smaller responsive design details (in this case, the position of the “add to cart” button).

Quick Setup

These demos can only be viewed via HTTP—you can’t open the index files in your browser, if you’ve cloned the repo and want to tinker with these pages locally. You have two options for running this locally without wading through a bunch of Apache nonsense:

PHP Server

OSX ships with PHP, which makes it very easy to spin up a quick server. Naviate to the repo’s root directory in your terminal and enter the following:

$ php -S localhost:7777

You should see something like:

Listening on http://localhost:7777
Document root is /Users/wilto/Sites/ricg/eq-demos
Press Ctrl-C to quit.

Then open http://localhost:7777/demos/(demo-name) in your browser

NodeJS

If you don’t have it installed already, you’ll need to install Node from https://nodejs.org/ (or brew install node, if you use Homebrew).

Once you have Node installed, navigate to the repo’s root directory in your terminal and enter the following:

$ npm install

This will install the node server’s dependencies. Once complete, enter:

$ node server.js

You should see something like:

Listening on http://localhost:7777
Document root is /Users/wilto/Sites/ricg/eq-demos
Press Ctrl-C to quit.

Then open http://localhost:7777/demos/(demo-name) in your browser

Demo Syntax

Only .element:media( min-width ) {} and .element:media( max-width ) {} are available so far.

The container query pseudo-polyfill used here is a modified version of element-query.

Motivation

Container Queries are the natural and much-needed evolution of Media Queries.

Where Media Queries are concerned with the viewport size, Container Queries are concernes with the styling child elements based on the size of a parent element. As a result, Container Queries allow content to adapt to a wide range of viewing experiences without having to change the content itself.

They also simplify stylesheets by removing the need to specify layout conditions between the screen and the element being styled.

Use cases

The simpliest use case is: “I have a widget that needs to look good in any column of our layout, whether that column is small, medium, or large.”

Use cases are more fully documented in the Use Cases and Requirements for Container Queries Editor’s Draft.

cq-demos's People

Contributors

wilto avatar jonathantneal avatar stonehippo avatar

Stargazers

Royer Adames avatar Gallium Wang avatar Thanasis G avatar Ayate0 avatar Piotr Porzuczek avatar  avatar Danilo Martins avatar Markus Müller avatar Sébastien Corne avatar matthiasg avatar Alexander Bachmann avatar Petr Kasparek avatar Erik van Gameren avatar Heitor Althmann avatar Teles avatar  avatar Marcus Morba avatar Deryost avatar Geir Kristian Thunem avatar Eric Portis avatar Jason Miller avatar Torleif Halseth avatar  avatar Brian McCarthy avatar Eevee Kreevee avatar Jake Rayson avatar Loïc Goyet avatar Jason San Jose avatar Chris Hart avatar Mark Dalgleish avatar Darin Reid avatar Hiswe avatar Michael Born avatar Chris Wright avatar Westley Knight avatar Zachary Brady avatar Simon Eramo avatar Glenn Jorde avatar Tim avatar Joe Kocovsky avatar Matt Duffin avatar Esko Pyyluoma avatar Roland Schaub avatar Heather Tovey avatar Chris Coleman avatar Ronni Chidekel avatar Dmitry Kiselyov avatar Andrew Fuller avatar Patrick Arminio avatar Dan Manchester avatar Michel Fiege avatar Anders D. Johnson avatar Robert K. Bell avatar Daniel Nocket avatar William Vercken de Vreuschmen avatar Cal Wilson avatar Ron Waldon-Howe avatar Veit Lehmann avatar Jason Niemi avatar Matt Zimmermann avatar Matthew Jackson avatar Joey Baker avatar Rick Davies avatar Boris Plamenov Karaivanov avatar Michael Gehrmann avatar Danilo Vega avatar Po-Ying Chen avatar Paul d'Aoust avatar Chris Bracco avatar Daniel Reid avatar Nick F avatar Charlie Cathcart avatar Ricky Sandoval avatar Christian Oliff avatar

Watchers

Dave Rupert avatar  avatar  avatar Martin Auswöger avatar  avatar Rick Davies avatar Anders D. Johnson avatar Cory Brown avatar Tab Atkins Jr. avatar Yoav Weiss avatar Andrew Norell avatar James Cloos avatar Matt Duffin avatar Zachary Brady avatar Alan Mooiman avatar Chris Wright avatar Eric Portis avatar Brian McCarthy avatar Ricky Sandoval avatar Royer Adames avatar

cq-demos's Issues

Error on docs

The page of link for "Use Cases and Requirements for Container Queries Editor’s Draft" is 404 error now.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.