Skip to content

Commit 60146f4

Browse files
author
Meredith G Hoo
committed
fixed even row offset for responsiveness
1 parent ced072b commit 60146f4

File tree

2 files changed

+13
-19
lines changed

2 files changed

+13
-19
lines changed

css/secrets.css

Lines changed: 2 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -8,23 +8,18 @@ body {
88
.row {
99
display: flex;
1010
}
11-
.row:nth-child(2n) {
12-
position: relative;
13-
left: -75px;
14-
}
15-
1611
svg {
1712
margin: 8px;
1813
}
1914

2015
.cell:hover, .cell:visited, .cell:focus {
21-
animation: loaderAnim 5s ease-in-out infinite normal forwards;
16+
animation: rotate 5s ease-in-out infinite normal forwards;
2217
padding: 0;
2318
margin: 0;
2419
}
2520

2621

27-
@keyframes loaderAnim {
22+
@keyframes rotate {
2823
0% {
2924
transform:rotate(0deg);
3025
}
@@ -35,13 +30,3 @@ svg {
3530
transform:rotate(0deg);
3631
}
3732
}
38-
@media only screen and (max-width: 450px) {
39-
.row:nth-child(2n) {
40-
position: relative;
41-
left: 75px;
42-
}
43-
body {
44-
left: -100px;
45-
top: 10px;
46-
}
47-
}

js/2secrets.js

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ function setup() {
2828
makeGrid(rows, cols);
2929
shapes = makeFlowers(radius);
3030
addSvgsToCells(size, padding);
31+
offsetEvenRows(size);
3132
}
3233

3334
function addSvgsToCells(size, padding) {
@@ -43,13 +44,21 @@ function addSvgsToCells(size, padding) {
4344
});
4445
}
4546

47+
function offsetEvenRows(size) {
48+
$(".row").each(function (index, object) {
49+
if (index % 2) {
50+
$(object).css("position", "relative");
51+
$(object).css("left", size / 2 * - 1 + "px");
52+
}
53+
});
54+
}
55+
4656
function makeGrid(rows, cols) {
4757
$('body').empty();
4858
for (var r = 0; r < rows; r++) {
4959
var rowId = "row" + r;
5060
var row = $("<div/>").addClass("row").attr("id", rowId).appendTo('body');
51-
var vi = r / (rows - 1);
52-
for (var c = 0; c < cols; c++) {
61+
for (var c = 0; c < cols + 1; c++) {
5362
var cellId = "cell" + ((r * rows) + c);
5463
$(row).append('<div class="cell" id="' + cellId + '"></div>');
5564
}

0 commit comments

Comments
 (0)