Last active
December 30, 2015 02:19
-
-
Save thibaultcha/7761795 to your computer and use it in GitHub Desktop.
Responsive grid layout system with a LESS script. This is a clone of http://zurb.com/playground/css-grid-builder Demo available here http://jsfiddle.net/thibaultCha/kKBZT/ Customize @nbcols, @Colwidth and @gutterwidth
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
* { | |
-webkit-box-sizing:border-box; | |
-moz-box-sizing:border-box; | |
box-sizing:border-box; | |
} | |
.container { | |
position: relative; | |
width: 590px; | |
margin: 0 auto; | |
padding: 0; | |
.row { | |
margin: 0 0 10px -10px; | |
} | |
.column:after, .row:after { content: ' '; display: block; height: 0; clear: both; visibility: hidden; } | |
} | |
/* Loop */ | |
@nbcols: 12; | |
@colwidth: 40; | |
@gutterwidth: 10; | |
.loop (@index, @type) when (@index > 0) { | |
(~".@{type}col_width_@{index}") { | |
@cumulmargin: (@index - 1)*@gutterwidth; | |
@width: @index*@colwidth+@cumulmargin; | |
float: left; | |
display: inline; | |
margin: 0 0 0 ~"@{gutterwidth}px"; | |
background-color: #ccc; | |
width: ~"@{width}px"; | |
} | |
(~".@{type}col_width_@{index}:before") { | |
content: "@{index}"; | |
} | |
(~".@{type}col_offset_by_@{index}") { | |
@cumulmargin: (@index + 1)*@gutterwidth; | |
@marginleft: @index*@colwidth+@cumulmargin; | |
margin-left: ~"@{marginleft}px"; | |
} | |
.loop(@index - 1, @type); | |
} | |
@media (min-width:991px) { | |
.loop (@nbcols, ''); | |
} | |
@media (max-width:990px) { | |
.loop (@nbcols, 'm_'); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!doctype html> | |
<html> | |
<head> | |
<title>ECE - Columns</title> | |
<meta charset="UTF-8"> | |
<link rel="stylesheet" href="grid.css"> | |
<style type="text/css"> | |
.container .row { | |
text-align: center; | |
} | |
footer { | |
width: 500px; | |
margin: 0 auto; | |
padding: 20px 0; | |
text-align: center; | |
} | |
</style> | |
</head> | |
<body> | |
<div class="container"> | |
<div class="row"> | |
<div class="col_width_12 m_col_width_12"></div> | |
</div> | |
<div class="row"> | |
<div class="col_width_6 m_col_width_3"></div> | |
<div class="col_width_6 m_col_width_3 m_col_offset_by_3"></div> | |
</div> | |
<div class="row"> | |
<div class="col_width_3 m_col_width_3"></div> | |
<div class="col_offset_by_3 col_width_6 m_col_width_9"></div> | |
</div> | |
<div class="row"> | |
<div class="col_width_12 m_col_width_12"></div> | |
</div> | |
</div> | |
<footer> | |
<p>Thibault Charbonnier</p> | |
</footer> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment