Comments (2)
I was looking for this example as well. Here's what I came up with:
<?php
/* This example addresses the whitespace issue described at
https://github.com/csswizardry/csswizardry-grids#classes-in-markup */
$i = 1;
$totalItems = 4; // total number of grid items
while ( $i <= $totalItems ) {
if ( $i == 1 ) {
/* Echo opening tag of first item only.
Subsequent opening tags handled at bottom of loop. */
echo '<div class="grid__item desk--one-fourth">';
}
// Content
if ( $i < $totalItems ) {
/* There are still more items after this item.
Echo closing tag and opening tag of next item.
Empty comment collapses white space. */
echo '</div><!--
--><div class="grid__item desk--one-fourth">';
} else {
/* There are no more items after this item.
Echo closing tag only. */
echo '</div>';
}
$i++;
}
Edit: Made a gist for future reference.
from csswizardry-grids.
Hi!
Sorry for letting this go stale :(
Try pasting the following into the codepad site:
<style>
.grid__item {
display: inline-block;
}
.one-third {
width: 33.333333333%;
}
</style>
<div class="grid">
<!--
<?php
$items = array('foo', 'bar', 'baz');
foreach ($items as $item) {
?>
--><div class="grid__item one-third"><?= $item ?></div><!--
<?php
}
?>
-->
</div>
Items from a loop without the need for a counter :)
from csswizardry-grids.
Related Issues (20)
- Should swallow up Avalon.gs
- Unnecessary selector bloat with grid modifiers HOT 1
- Using breakpoints in media queries HOT 3
- Using mixin grid-media-query for multiple breakpoints HOT 4
- Using mixin grid-media-query for multiple breakpoints v2.0 HOT 1
- add 'main' property in bower.json
- Lack of configuration informations in the documentation
- Small typo in the README
- Your Tutorial For 5-Column Grid
- Cannot get responsive silent classes to work with Grunt HOT 8
- Your grid is broken when using columns 11/12, 1/12 HOT 6
- UI Tests via CSS HOT 2
- Support of other preprocessors
- ask for less version
- nth-child and media query breaks system
- Help for displaying image and text differently on desktop and mobile
- Possible fix to avoid the empty HTML comments HOT 1
- twelfths -> twelthfs HOT 1
- No index.html
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from csswizardry-grids.