Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Recursion demo #2

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ This repo uses a modified version of [Rob Brackett’s](https://github.com/Mr0gr
**[Whitworth](http://responsiveimagescg.github.io/ALA-Whitworth-Demo/demo1/index.html)**<br>
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).

**Recursion**<br>
Illustrates that container queries can still (as element queries) result in an infinite loop.

## 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:
Expand Down
26 changes: 26 additions & 0 deletions demos/recursion/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Element Query Demo</title>
<meta name="viewport" content="width=device-width, initial-scale=1">

<link rel="stylesheet" type="text/css" href="styles.css">

<script src="../../lib/element-queries.js"></script>
<script src="../../lib/parser.js"></script>

</head>

<body>
<h1>Recursion</h1>
<p>Container queries can still (as element queries) result in an infinite loop.</p>
<p>Resize the browser to see it flashing.</p>

<div class="demo">
<div class="container">
<div class="inner"></div>
</div>
</div>
</body>
</html>
14 changes: 14 additions & 0 deletions demos/recursion/styles.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
.container {
/* Let the width of the container depend on its contents */
display: inline-block;
}
.inner {
width: 15em;
height: 15em;
background: red;
color: white;
}
.container:media(min-width: 10em) > .inner {
width: 5em;
background: green;
}