A Pen by Anton Vynogradenko on CodePen.
Created
September 10, 2015 21:49
-
-
Save Restuta/3cb2035634e77c08d521 to your computer and use it in GitHub Desktop.
Bootstrap Grid Visualized
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
html | |
body | |
#to-clone.floating-name.hidden <!-- used to clone with jQuery--> | |
.container | |
.spacer | |
.row | |
.col-sm-4 | |
.col-sm-8.green | |
.spacer.text-center | |
.row | |
.col-sm-4 | |
.row | |
.col-sm-1 | |
.col-sm-1 | |
.col-sm-4.green |
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
$(() => { | |
var $floatingNameDiv = $('#to-clone') | |
.clone() | |
.removeAttr('id') | |
.removeClass('hidden') | |
.addClass('floating-name'); | |
var regexToGetColNum = /col-\w\w-(\d\d?)/; | |
$('[class^="col-"]').each((index, el) => { | |
var $el = $(el); | |
var colNum = $el.attr('class').match(regexToGetColNum)[1]; | |
var $nameDiv = $floatingNameDiv.clone().append(colNum); | |
$el.append(' '); | |
$el.append($nameDiv); | |
var hasChildren = ($el.find('[class^="col-"]').length > 0); | |
if (hasChildren) { | |
$el.addClass('bg-pink-faded'); | |
} else { | |
$el.addClass('bg-pink'); | |
} | |
}); | |
}); |
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
<script src="//cdnjs.cloudflare.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script> |
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
$bg-color: lighten(grey, 40%); | |
$col-color: lightpink; | |
.bg-pink { | |
background-color: $col-color; | |
} | |
.bg-pink-faded { | |
background-color: rgba($col-color, 0.5); | |
} | |
.container { | |
background: $bg-color; | |
} | |
.spacer { | |
height: 30px; | |
margin-left: -15px; | |
margin-right: -15px; | |
background: $bg-color; | |
} | |
[class^="col-"] { | |
border: 1px solid $bg-color; | |
} | |
.floating-name { | |
position: absolute; | |
left:0px; | |
top: 10%; | |
color: rgba(255, 255, 255, 0.6); | |
margin-left: 50%; | |
margin-right: 50%; | |
z-index: 100; | |
font-size: 12px; | |
} | |
.pink { background-color: lightpink;} | |
.green {background-color: mediumaquamarine;} |
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
<link href="//maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css" rel="stylesheet" /> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment