Vertical div container does not render with calc() - Opera/Safari - html

I have two ratio div containers and a splitter bar div among. Unfortunately the bottom container is not rendered by Opera or Safari. How to conjure up the bottom one by keeping the calc() concept?
function GetHeight() {
var element = document.getElementById("bottomContent");
if (element) {
if (element.getBoundingClientRect) {
var rect = element.getBoundingClientRect();
var absHeight = getAbsoluteHeight(element);
alert(" rectHeight: " + rect.height + "\n offset height: " + element.offsetHeight + "\n client height: " + element.clientHeight + "\n abs height: " + absHeight);
} else {
alert("Browser does not support!");
}
} else {
alert("No element!");
}
}
function getAbsoluteHeight(el) {
el = (typeof el === 'string') ? document.querySelector(el) : el;
var styles = window.getComputedStyle(el);
var margin = parseFloat(styles['marginTop']) +
parseFloat(styles['marginBottom']);
return Math.ceil(el.offsetHeight + margin);
}
html,
body {
height: 95%;
}
.content {
background: rgba(221, 221, 221, 0.41);
min-width: 5px;
width: 100%;
height: 100%;
}
.splitCntainerVertical {
width: 100%;
height: 100%;
min-width: 5px;
margin: auto;
overflow: hidden;
}
.splitCntainerTopContent {
width: 100%;
min-height: 5px;
margin: auto;
overflow: hidden;
}
.splitCntainerBottomContent {
width: 100%;
min-height: 5px;
margin: auto;
overflow: hidden;
}
.splitterVertical {
border-radius: 2px;
background: rgba(31, 37, 37, 0.41);
margin-top: 10px;
margin-bottom: 10px;
height: 5px;
width: 100%;
cursor: n-resize;
}
<button onclick="GetHeight()">Get bottom container height</button>
<div class="splitCntainerVertical">
<div class="splitCntainerTopContent" style="height:65%;">
<div class="content"></div>
</div>
<div id="splitter" class="splitterVertical"></div>
<div id="bottomContent" class="splitCntainerBottomContent" style="height: calc(35% - 25px);">
<div class="content"></div>
</div>
</div>
Any idea?

Related

Everything disappears when wrapped in a "block" element

I am working with this parallaxish 3d effect i found in a codepen. However I need to add an additional wrapper around all the html. When i wrap the html contents in a <div> everything disappears. When I wrap it in a <span> tag everything is fine. Also if i set that <span> tag to display:block; everything disappears again.
Why is this happening when wrapped in a block element?
Thanks!
https://codepen.io/anon/pen/JapeJX
When you add display: block make sure u set its height to 100% as its inner elements have height set in %.
Checkout https://stackoverflow.com/a/5658062/7333443
CodePen: https://codepen.io/anon/pen/QVQJPR
!(function ($doc, $win) {
var screenWidth = $win.screen.width / 2,
screenHeight = $win.screen.height / 2,
$elems = $doc.getElementsByClassName("elem"),
validPropertyPrefix = "",
otherProperty = "perspective(1000px)",
elemStyle = $elems[0].style;
if (typeof elemStyle.webkitTransform == "string") {
validPropertyPrefix = "webkitTransform";
} else if (typeof elemStyle.MozTransform == "string") {
validPropertyPrefix = "MozTransform";
}
$doc.addEventListener("mousemove", function (e) {
var centroX = e.clientX - screenWidth,
centroY = screenHeight - (e.clientY + 13),
degX = centroX * 0.02,
degY = centroY * 0.01,
$elem;
for (var i = 0; i < $elems.length; i++) {
$elem = $elems[i];
$elem.style[validPropertyPrefix] =
otherProperty + "rotateY(" + degX + "deg) rotateX(" + degY + "deg)";
}
});
})(document, window);
/* CREDITS TO DESKTOPOGRAPHY FOR IMAGE USED */
html,
body {
width: 100%;
height: 100%;
}
body {
background: #004382;
overflow: hidden;
}
.wrapper {
transform-style: preserve-3d;
margin: 0 auto;
max-width: 982px;
width: 100%;
height: 100%;
position: relative;
display: flex;
justify-content: center;
align-self: center;
background: url("http://portalpacific.net/img/desk/icon-circles.png")
no-repeat center center;
background-size: contain;
}
.bloc {
height: 100%;
width: 100%;
position: relative;
display: flex;
justify-content: center;
align-self: center;
background-size: contain;
background-position: center;
}
.content {
transform: translateZ(80px) scale(1);
-webkit-transform: translateZ(80px) scale(1);
height: 100%;
width: 100%;
max-width: 720px;
position: absolute;
margin: auto;
color: #fff;
z-index: 3;
}
.content1 {
background: url("http://portalpacific.net/img/desk/Website.png") no-repeat;
background-position: center;
max-width: 982px;
width: 100%;
height: 100%;
position: relative;
display: flex;
justify-content: center;
align-self: center;
background-size: contain;
}
.content p:nth-of-type(1) {
font-size: 36px;
line-height: 60px;
position: absolute;
}
.content p:nth-of-type(2) {
position: absolute;
}
.block {
display: block;
height: 100%;
}
<span class="block">
<div class="wrapper elem" style="transform: perspective(700px) rotateY(0deg) rotateX(0deg);">
<div class="bloc">
<div class="content content1"></div>
<div class="content content2">
</div>
</div>
</div>
</span>

Arrange 2 divs diagonally inside a parent div

I'm trying to arrange 2 divs inside a parent div so that is looks like the parent div is being divided into 2 parts diagonally. The diagram below will show what is required
This is the code i have tried.
App.js
import React, { Component } from "react";
import "./App.css";
class InnerMainDiv extends Component {
constructor() {
super();
this.section = React.createRef();
}
componentDidMount() {
this.handleResize();
window.addEventListener("resize", this.handleResize);
}
componentWillUnmount() {
window.addEventListener("resize", null);
}
handleResize = (WindowSize, event) => {
let h = this.section.current.clientHeight;
let w = this.section.current.clientWidth;
let angle = Math.atan(h / w) * 57.29577;
let rotateProperty = "rotate(" + angle + "deg)";
this.section.current.style.webkitTransform = rotateProperty;
this.section.current.style.transform = rotateProperty;
this.section.current.style.mozTransform = rotateProperty;
};
render() {
return (
<div className="maindiv">
<section ref={this.section}>
<div href="#1" />
</section>
<section ref={this.section}>
<div href="#2" />
</section>
</div>
);
}
}
export default InnerMainDiv;
App.css
html,
body,
div {
height: 100%;
width: 100%;
padding: 0;
margin: 0;
}
div {
overflow: hidden;
position: relative;
}
section {
position: absolute;
top: -100%;
height: 5000vw;
width: 5000vh;
background: #ccc;
-webkit-transform-origin: 0 0;
-moz-transform-origin: 0 0;
transform-origin: 0 0;
}
section + section {
background: #666;
top: 0%;
}
section div {
display: block;
width: 100%;
height: 100%;
cursor: pointer;
}
Any ideas or suggestions on how to achieve this?.
You can use clip-path to achieve this:
.container {
width: 200px;
height: 200px;
position: relative;
}
.container > * {
height: 100%;
background: red;
}
.container :last-child {
position: absolute;
top: 0;
left: 0;
width: 100%;
background: blue;
-webkit-clip-path: polygon(0 0, 100% 0%, 100% 100%);
clip-path: polygon(0 0, 100% 0%, 100% 100%);
}
<div class="container">
<div></div>
<div></div>
</div>
But in case you want more browser support you can use rotation like this:
.container {
width: 200px;
height: 200px;
position: relative;
overflow:hidden;
}
.container > * {
height: 100%;
background: red;
}
.container :last-child {
position: absolute;
top: 0;
left: 0;
width: 141%; /* = 1.41 * 100% --> 1.41 = sqrt(2) */
height: 141%;
background: blue;
transform-origin:top left;
transform:rotate(-45deg);
}
<div class="container">
<div></div>
<div></div>
</div>

Parallax background with inside text

I have parallax background that's moving at a certain speed with javascript. I need to put the text inside those background divs, so each background has its own text block. But when I put the text inside it goes to the top of the page, despite the container it's located. Something in the positions needs to change but I'm not sure what exactly. Any ideas?
HTML
<div id='hero'>
<div class='layer-bg layer' data-depth='0.10' data-type='parallax'>
<img class="logo" />
</div>
<div class='layer-1 layer' data-depth='0.20' data-type='parallax'>
</div>
<div class="relative">
<div class='layer-2 layer' data-depth='0.30' data-type='parallax'>
<div class="video">
Text
</div>
</div>
</div>
<div class='layer-3 layer' data-depth='0.40' data-type='parallax'></div>
</div>
<div id='hero-mobile'></div>
CSS
body {
padding: 0;
margin: 0;
background-color: $bronze;
font-family: 'Playfair Display', serif;
color: $white;
}
//
#hero {
height: $heroHeight;
overflow: hidden;
position: relative;
}
#content {
background-color: $bronze;
}
.layer {
background-position: bottom center;
background-size: auto;
background-repeat: no-repeat;
width: 100%;
height: $heroHeight;
position: fixed;
z-index: -1;
}
.first-section {
padding: 50px 0 20px 0;
}
.text-header {
font-size: 50px;
text-align: center;
}
h1 {
line-height: 120%;
margin-bottom: 30px;
}
p {
color: #ede0d5;
font-size: 18px;
line-height: 150%;
}
// #hero, .layer {
// min-height: 800px;
// }
.layer-bg {
background-image: url('');
height: 4000px!important;
background-position: top center;
width: 100%;
}
.layer-1 {
background-image: url('
');
height: 3000px;
}
.layer-2 {
background-image: url('');
height: 5500px;
}
.layer-3 {
background-image: url('
');
height: 8000px;
}
.layer-4 {
background-image: url('
');
background-position: center bottom;
}
.layer-overlay {
background-image: url('
');
}
.relative {
position: relative;
}
.logo {
margin: 0px auto;
max-width: 600px;
margin-top: 100px;
display: block;
}
JS
(function() {
window.addEventListener('scroll', function(event) {
var depth, i, layer, layers, len, movement, topDistance, translate3d;
topDistance = this.pageYOffset;
layers = document.querySelectorAll("[data-type='parallax']");
for (i = 0, len = layers.length; i < len; i++) {if (window.CP.shouldStopExecution(1)){break;}
layer = layers[i];
depth = layer.getAttribute('data-depth');
movement = -(topDistance * depth);
translate3d = 'translate3d(0, ' + movement + 'px, 0)';
layer.style['-webkit-transform'] = translate3d;
layer.style['-moz-transform'] = translate3d;
layer.style['-ms-transform'] = translate3d;
layer.style['-o-transform'] = translate3d;
layer.style.transform = translate3d;
}
window.CP.exitedLoop(1);
});
}).call(this);
I don't why you are using 8000px height in your CSS but
check the link may be it will be helpful for you
https://www.w3schools.com/howto/tryhow_css_parallax_demo.htm
Its because you fixed the position of every .layer class div that's why they all are in same position of your DOM.
And overflow: hidden; of your main div #hero
Solution
You have to remove fixed position of your .layer class and overflow: hidden;.
Example:- see fiddle

Need to slide one DIV on another DIV. Using only CSS

There should be a simple solution, but I can't work one out. I need div with class of geltona to slide onto div with class of zydra. I must use only css, but I can't. It might be obvious, but I can't find a solution as I am only using floats and % in width and height, so I can't really set a location where it should go by keyframes.
html,
body {
height: 100%;
width: 100%;
margin: 0;
padding: 0;
overflow: hidden;
}
p {
margin: 10px;
}
.header {
height: 5%;
width: 100%;
}
.geltona {
height: 15%;
width: 50%;
background-color: yellow;
float: left;
}
.zydra {
height: 15%;
width: 50%;
background-color: lightblue;
float: right;
}
.balta {
height: 30%;
width: 70%;
background-color: white;
float: left;
}
.juoda {
height: 75%;
width: 30%;
background-color: black;
float: right;
}
.oranzine {
height: 20%;
width: 35%;
background-color: orange;
display: inline;
float: left;
}
.melyna {
position: relative;
height: 45%;
width: 35%;
background-color: blue;
float: right;
}
.zalia {
height: 25%;
width: 35%;
background-color: green;
float: left;
}
.ruda {
height: 5%;
width: 100%;
background-color: brown;
float: left;
}
/* ANIMACIJOS */
/* 3. Blokas animuotai nukeliauja ant gretimo bloko, pilnai uždengęs gretimą bloką – išnyksta */
/* 20. Pasisuka nuo 45 laipsnių iki 0 laipsnių ir padidėja 30%; */
.zalia:hover {
animation: sukasi 3s;
}
#keyframes sukasi {
0%{transform: rotate(45deg)}
100%{transform: rotate(0deg) scale(1.3)};
}
/* 21. Nuotrauka atslenka iš viršaus ir mažėja (trukmė 5 sec); */
.header img {
position: absolute;
top: -145px;
max-width: 145px;
max-height: 145px;
background: transparent;
transition: 5s;
}
.header:hover img {
transition: 5s;
top: 0;
max-width: 45px;
max-height: 45px;
}
/* MEDIA QUERIES */
#media only screen and (max-width: 768px) and (max-height: 1024px){
.geltona {
height: 25%;
width: 100%;
}
.zydra {
display: none;
}
.balta {
height: 20%;
width: 70%;
}
.juoda {
height: 65%;
width: 30%;
}
.oranzine {
display: none;
}
.melyna {
height: 45%;
width: 40%;
}
.zalia {
height: 45%;
width: 30%;
}
}
<!DOCTYPE html>
<html>
<head>
<title>IPP Kursinis</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width" content="initial-scale=1">
<link rel="stylesheet" type="text/css" href="src/css/main.css">
</head>
<body>
<div class="header">
<img src="img/foto.jpg">
</div>
<div class="geltona"></div>
<div class="zydra"
id="keiciamaSpalva"
onmouseover="changeBackground(this.id, 'red', 'yellow');"
onmouseout="changeBackground(this.id, 'lightblue', 'black');">
<p>Lorem ipsum</p>
</div>
<div class="balta"
id="balta"
onmouseover="showClass();"
onmouseout="removeClass();">
</div>
<div class="juoda"></div>
<div class="oranzine"></div>
<div class="melyna">
<p id="demo"></p>
</div>
<div class="zalia"></div>
<div class="ruda"></div>
<!-- JAVASCRIPT prasideda nuo čia -->
<script type="text/javascript">
/* Keičiama teksto ir fono spalva pagal nurodymus. */
function changeBackground(id, color, textColor) {
document.getElementById(id).style.background = color;
document.getElementById(id).style.color = textColor;
};
/* Parodome bloko klasę ir ją ištriname, kad nesipildytų visas blokas*/
function showClass() {
var element = document.getElementById('balta');
element.innerHTML = element.innerHTML + "<p> Šio bloko klasė: "+element.className+"</p>";
};
function removeClass() {
document.getElementById('balta').innerHTML = "";
};
/* Rodoma lango, ekrano ir slankiklių informacija, tik tuomet, kai keičiame ekrano dydį. */
window.onresize = displayWindowSize;
function displayWindowSize(){
document.getElementById("demo").innerHTML =
"Ekrano plotis: " + screen.width + "<br>" +
"Ekrano aukštis: " + screen.height + "<br>" +
"Lango plotis: " + window.innerWidth + "<br>" +
"Lango aukštis: " + window.innerHeight + "<br>" +
"Slankiklio horizontali padėtis: " + window.scrollX + "<br>" +
"Slankiklio vertikali padėtis: " + window.scrollY;
};
</script>
</body>
</html>
With the least amount of changes for this code, I came up with this.
Wrap your two neighbouring containers (geltona and zydra) in another container (gelzy here) and give it the position:relative and the two child containers the position:absolute with left:0 and right:0 instead of the floats.
Make use of the transition on hover to move the geltona (with higher z-index)to 50% of the left to overlap on the blue container
.gelzy{
position:relative;
height:15%;
width:100%;
}
.geltona {
height: 100%;
width: 50%;
background-color: yellow;
left:0;
position: absolute;
z-index:2;
transition:left 1s ease-in-out;
}
.zydra {
height: 100%;
width: 50%;
background-color: lightblue;
right:0;
position: absolute;
}
.geltona:hover {
left:50%;
}
html,
body {
height: 100%;
width: 100%;
margin: 0;
padding: 0;
overflow: hidden;
}
p {
margin: 10px;
}
.header {
height: 5%;
width: 100%;
}
.gelzy{
position:relative;
height:15%;
width:100%;
}
.geltona {
height: 100%;
width: 50%;
background-color: yellow;
left:0;
position: absolute;
z-index:2;
transition:left 1s ease-in-out;
}
.zydra {
height: 100%;
width: 50%;
background-color: lightblue;
right:0;
position: absolute;
}
.geltona:hover {
left:50%;
}
.balta {
height: 30%;
width: 70%;
background-color: white;
float: left;
}
.juoda {
height: 75%;
width: 30%;
background-color: black;
float: right;
}
.oranzine {
height: 20%;
width: 35%;
background-color: orange;
display: inline;
float: left;
}
.melyna {
position: relative;
height: 45%;
width: 35%;
background-color: blue;
float: right;
}
.zalia {
height: 25%;
width: 35%;
background-color: green;
float: left;
}
.ruda {
height: 5%;
width: 100%;
background-color: brown;
float: left;
}
/* ANIMACIJOS */
/* 3. Blokas animuotai nukeliauja ant gretimo bloko, pilnai uždengęs gretimą bloką – išnyksta */
/* 20. Pasisuka nuo 45 laipsnių iki 0 laipsnių ir padidėja 30%; */
.zalia:hover {
animation: sukasi 3s;
}
#keyframes sukasi {
0% {
transform: rotate(45deg)
}
100% {
transform: rotate(0deg) scale(1.3)
}
;
}
/* 21. Nuotrauka atslenka iš viršaus ir mažėja (trukmė 5 sec); */
.header img {
position: absolute;
top: -145px;
max-width: 145px;
max-height: 145px;
background: transparent;
transition: 5s;
}
.header:hover img {
transition: 5s;
top: 0;
max-width: 45px;
max-height: 45px;
}
/* MEDIA QUERIES */
#media only screen and (max-width: 768px) and (max-height: 1024px) {
.geltona {
height: 25%;
width: 100%;
}
.zydra {
display: none;
}
.balta {
height: 20%;
width: 70%;
}
.juoda {
height: 65%;
width: 30%;
}
.oranzine {
display: none;
}
.melyna {
height: 45%;
width: 40%;
}
.zalia {
height: 45%;
width: 30%;
}
}
<!DOCTYPE html>
<html>
<head>
<title>IPP Kursinis</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width" content="initial-scale=1">
<link rel="stylesheet" type="text/css" href="src/css/main.css">
</head>
<body>
<div class="header">
<img src="img/foto.jpg">
</div>
<div class="gelzy">
<div class="geltona"></div>
<div class="zydra" id="keiciamaSpalva" onmouseover="changeBackground(this.id, 'red', 'yellow');" onmouseout="changeBackground(this.id, 'lightblue', 'black');">
<p>Lorem ipsum</p>
</div>
</div>
<div class="balta" id="balta" onmouseover="showClass();" onmouseout="removeClass();">
</div>
<div class="juoda"></div>
<div class="oranzine"></div>
<div class="melyna">
<p id="demo"></p>
</div>
<div class="zalia"></div>
<div class="ruda"></div>
<!-- JAVASCRIPT prasideda nuo čia -->
<script type="text/javascript">
/* Keičiama teksto ir fono spalva pagal nurodymus. */
function changeBackground(id, color, textColor) {
document.getElementById(id).style.background = color;
document.getElementById(id).style.color = textColor;
};
/* Parodome bloko klasę ir ją ištriname, kad nesipildytų visas blokas*/
function showClass() {
var element = document.getElementById('balta');
element.innerHTML = element.innerHTML + "<p> Šio bloko klasė: " + element.className + "</p>";
};
function removeClass() {
document.getElementById('balta').innerHTML = "";
};
/* Rodoma lango, ekrano ir slankiklių informacija, tik tuomet, kai keičiame ekrano dydį. */
window.onresize = displayWindowSize;
function displayWindowSize() {
document.getElementById("demo").innerHTML =
"Ekrano plotis: " + screen.width + "<br>" +
"Ekrano aukštis: " + screen.height + "<br>" +
"Lango plotis: " + window.innerWidth + "<br>" +
"Lango aukštis: " + window.innerHeight + "<br>" +
"Slankiklio horizontali padėtis: " + window.scrollX + "<br>" +
"Slankiklio vertikali padėtis: " + window.scrollY;
};
</script>
</body>
</html>

Indent even rows of hexagons in CSS

I currently have a list of hexagons (images) that I have wrap to the next line when the browser width decreases. However, when this happens, they form even lines as seen in the first image, each starting at the same point on the x axis.
Here is the JS Fiddle (albeit, the hexes don't flow right because they aren't images). The real code for this is:
<div class="container">
<span>
<img class="hex" src="img/hex.png">
</span>
...
</div>
And the CSS is:
.container {
padding-top: 80px;
width: 50%;
margin-left: auto;
margin-right: auto;
}
.container span {
line-height: 129px;
display: inline-block;
}
.container .hex {
display: block;
margin-left: auto;
margin-right: auto;
}
What I would like to do is alternate the rows such that every other row starts at an offset of the hexagon size as seen in figure two. It should also be noted that this example also has a negative y position relative to the respective position as determined from the first image.
Is there a way to do this with just CSS? I'd like to avoid using a library if at all possible.
This is similar to the question asked here, but I need the entire structure to be able to have an undetermined number of rows, so the solution where I specify which items are in which rows isn't feasible for my application.
Solution in JS Fiddle Demo :
Demo 1 :
http://jsfiddle.net/mkginfo/bhxohocv/
HTML Code :
<div class="container">
<!-- odd line -->
<span>
<div class="hexagon"> </div>
</span>
<span>
<div class="hexagon"> </div>
</span>
<span>
<div class="hexagon"> </div>
</span>
<!-- even line -->
<span class="odd">
<div class="hexagon"> </div>
</span>
<span>
<div class="hexagon"> </div>
</span>
<!-- odd line -->
<span>
<div class="hexagon"> </div>
</span>
<span>
<div class="hexagon"> </div>
</span>
<span>
<div class="hexagon"> </div>
</span>
</div>
CSS Code :
.container {
padding-top: 80px;
width: 65%;
margin-left: auto;
margin-right: auto;
}
.container span {
line-height: 129px;
display: inline-block;
position: relative;
margin-bottom: 25px;
}
.container span.odd {
line-height: 129px;
display: inline-block;
position: relative;
margin-bottom: 25px;
margin-left: 52px;
margin-top: -20px;
}
.container .hex {
display: block;
margin-left: auto;
margin-right: auto;
}
.hexagon {
width: 100px;
height: 55px;
background: red;
position: relative;
}
.hexagon:before {
content: "";
position: absolute;
top: -25px;
left: 0;
width: 0;
height: 0;
border-left: 50px solid transparent;
border-right: 50px solid transparent;
border-bottom: 25px solid red;
}
.hexagon:after {
content: "";
position: absolute;
bottom: -25px;
left: 0;
width: 0;
height: 0;
border-left: 50px solid transparent;
border-right: 50px solid transparent;
border-top: 25px solid red;
}
Demo 2 :
http://jsfiddle.net/mkginfo/wnsjfwt0/
Here's a solution that uses javascript to add the necessary transformations to the elements.
CSS:
.container {
padding-top: 80px;
width: 65%;
margin-left: auto;
margin-right: auto;
}
.floatBox {
margin-left: 15px;
margin-right: 15px;
}
.floatBox div {
display: inline-block;
}
.floatBox div.odd {
margin-left: 67px;
}
JS:
var floatBox = $(".floatBox");
var elements = floatBox.children();
var numElements = elements.length;
//reset all styles so they don't compound
elements.removeClass("odd");
elements.css("transform", "translateY(0)");
elements.css("-ms-transform", "translateY(0)");
elements.css("-webkit-transform", "translateY(0)");
var width = $(window).width() *.65;
var evenRowWidth = Math.floor(width / 135);
var oddRowWidth = Math.max(evenRowWidth - 1, 1);
var numberOfRows = 0;
var floatBoxWidth = evenRowWidth *138;
var delta = Math.floor((width-floatBoxWidth)/2);
floatBox.css("margin-left", delta);
floatBox.css("margin-right", delta);
var test = numElements;
var j = 2;
while (test > 0)
{
if (j % 2 == 0)
{
test -= evenRowWidth;
}
else
{
test -= oddRowWidth;
}
numberOfRows++;
j++;
}
j = 0;
var actionRow = 2;
var rowCount = 1;
var first = true;
for (var i = evenRowWidth; i < numElements; i++)
{
var translationAmt = -37*(actionRow-1);
if (actionRow % 2 == 0 && first)
{
first = true;
}
if (first)
{
$(elements.get(i)).addClass("odd");
first = false;
}
$(elements.get(i)).css("transform", "translateY(" + translationAmt + "px)");
$(elements.get(i)).css("-ms-transform", "translateY(" + translationAmt + "px)");
$(elements.get(i)).css("-webkit-transform", "translateY(" + translationAmt + "px)");
if (actionRow % 2 == 0)
{
if (rowCount == oddRowWidth)
{
actionRow++;
rowCount = 0;
}
}
else
{
if (rowCount == evenRowWidth)
{
actionRow++;
rowCount = 0;
first = true;
}
}
rowCount++;
}
HTML:
<div class="container">
<div class="floatBox">
<div>
<span>
<img src="image.png">
</span>
</div>
...
</div>
</div>