Jquery animate() opacity working but animating right does not? - javascript

Hi i am trying to animate to the right but it doesn't seem to be working but opacity change does work in the same function?
$(document).on("click touchstart tap", ".buttonchat", function () {
$('.message').each(function(i) {
delay =(i)*500;
$(this).delay(delay).animate({
opacity: 0,
right: "-150px"
},1000, function() {
// Animation complete.
});
});
});
as you can see in this pen animating to the right does nothing but changing opacity works what's happening?
pen: https://codepen.io/uiunicorn/pen/YzZXwJp
thanks in advance

Your messages span will have to have the position: absolute property...
<span class="message" style="width: 18.2105rem; height: 1.26316rem; opacity: 1; position:absolute;">Hello! 👋 I hope you're having a good night</span>
Here's a working pen: https://codepen.io/paulmartin91/pen/RwpPaPL
Here's the explanation from W3 Schools:
By default, all HTML elements have a static position, and cannot be
moved. To manipulate the position, remember to first set the CSS
position property of the element to relative, fixed, or absolute!

In CSS file you should consider adding "." in the beginning.
and Js file here below with corrections.
$(document).on("click touchstart tap", ".buttonchat", function () {
$('.message').each(function(i) {
delay =(i)*500;
$(this).delay(delay).animate({
"opacity": 0.20 ,
"right": "0px" , "top": "0px" , "background-color" : "green"
},1000, function() {
// Animation complete.
});
});
});
.message{
left: 0px;
position : absolute ;
}
.relative{ position : relative ; }
<button style="width: 200px; height: 100px" class="buttonchat"></button>
<div class="message-main relative">
<div class="message-hold">
<div class="messages">
<div
class="bubble cornered left"
style="
opacity: 1;
width: 19.2105rem;
height: 2.47368rem;
margin-top: 0px;
margin-left: 0px;
transform: scale(1);
"
>
<div class="loading" style="transform: translateX(0rem) scale(1)"
><b style="opacity: 0; transform: scale(0)">•</b
><b style="opacity: 0; transform: scale(0)">•</b
><b style="opacity: 0; transform: scale(0)">•</b></div
><div
class="message"
style="width: 18.2105rem; height: 1.26316rem; opacity: 1"
>Hello! 👋 I hope you're having a good night</div
>
</div>
<br />
<div
class="bubble cornered left"
style="
opacity: 1;
width: 15.7368rem;
height: 2.47368rem;
margin-top: 0px;
margin-left: 0px;
transform: scale(1);
"
>
<div class="loading" style="transform: translateX(0rem) scale(1)"
><b style="opacity: 0; transform: scale(0)">•</b
><b style="opacity: 0; transform: scale(0)">•</b
><b style="opacity: 0; transform: scale(0)">•</b></div
><div
class="message"
style="width: 14.7368rem; height: 1.26316rem; opacity: 1"
>I'm a junior interactive designer 😎</div
>
</div>
<br />
<div
class="bubble cornered left"
style="
opacity: 1;
width: 23.8947rem;
height: 2.47368rem;
margin-top: 0px;
margin-left: 0px;
transform: scale(1);
"
>
<div class="loading" style="transform: translateX(0rem) scale(1)"
><b style="opacity: 0; transform: scale(0)">•</b
><b style="opacity: 0; transform: scale(0)">•</b
><b style="opacity: 0; transform: scale(0)">•</b></div
>
<div
class="message"
style="width: 22.8421rem; height: 1.26316rem; opacity: 1"
>
which basically means I create cool looking websites 🤘
</div>
</div>
<br />
<div
class="bubble cornered left"
style="
opacity: 1;
width: 30.9474rem;
height: 2.47368rem;
margin-top: 0px;
margin-left: 0px;
transform: scale(1);
"
>
<div class="loading" style="transform: translateX(0rem) scale(1)"
><b style="opacity: 0; transform: scale(0)">•</b
><b style="opacity: 0; transform: scale(0)">•</b
><b style="opacity: 0; transform: scale(0)">•</b></div
><div
class="message"
style="width: 29.9474rem; height: 1.26316rem; opacity: 1"
>I have exactly 0 qualifications and mostly get by using stackoverflow
👀</div
>
</div>
<br />
<div
class="bubble cornered left"
style="
opacity: 1;
width: 20.3158rem;
height: 2.47368rem;
margin-top: 0px;
margin-left: 0px;
transform: scale(1);
"
>
<div class="loading" style="transform: translateX(0rem) scale(1)"
><b style="opacity: 0; transform: scale(0)">•</b
><b style="opacity: 0; transform: scale(0)">•</b
><b style="opacity: 0; transform: scale(0)">•</b></div
><div
class="message"
style="width: 19.3158rem; height: 1.26316rem; opacity: 1"
>Now I have your full confidence let's move on!</div
>
</div>
<br />
</div>
</div>
</div>

Related

Use same javascript function for different overlay IDs

I want to display the overlay for different links. 1st overlay has an image and text whereas if we click link2 it must display overlay2 having same structure but diff content. Please help me get the desired output.
function on() {
document.getElementById("overlay").style.display = "block";
}
function on1() {
document.getElementById("overlay1").style.display = "block";
}
function off() {
document.getElementById("overlay").style.display = "none";
}
.img {
transition: transform 5s ease-in-out;
transform: scale(1);
transform-origin: 0 0;
}
.img:hover {
transform: scale(1.25)
}
#overlay,
#overlay1 {
position: fixed;
display: none;
width: 100%;
height: 100%;
top: 0;
left: 0;
right: 0;
bottom: 0;
background-color: white;
z-index: 77777772;
cursor: pointer;
}
#text,
#text1 {
position: fixed;
top: 20%;
left: 5%;
//font-size: 50px;
color: black;
// transform: translate(-50%,-50%);
// -ms-transform: translate(-50%,-50%);
}
<div id="overlay" onclick="off()">
<div id="text">
<div style="width: 48%; float:left">
<h2>XXX</h2>
<h4>ZZZ</h4>
<p style="font-size:14px;">
Help bring forth the immense talent that resides amongst the valley’s citizens. </p>
</div>
<div style="width: 50%; float:right; margin-top:-220px;
">
<img class="img" style="height:100%" src="http://cdn.dpmag.com/2016/06/boydB3_6881-683x1024.jpg">
</div>
</div>
<div style="padding:20px">
<h2></h2>
<a onclick="on()"></a>
</div>
<div id="overlay1" onclick="on1()">
<div id="text1">
<div style="width: 48%; float:left">
<h2>AAA</h2>
<h4>MMM</h4>
<p style="font-size:14px;">Help bring forth the immense talent that resides amongst the valley’s citizens. </p>
</div>
<div style="width: 50%; float:right; margin-top:-220px;
">
<img class="img" style="height:100%" src="http://cdn.dpmag.com/2016/06/002boydB37683-703x1024.jpg">
</div>
</div>
<div style="padding:20px">
<h2></h2>
<a onclick="on1()"></a>
</div>
</div>
</div>
<a onclick="on(id)"style="font-size: 11pt;">Read More -></a>
<a onclick="on(id)"style="font-size: 11pt;">Read More -></a>
1. List item
There are better ways to achieve this, however as per your requirement you may pass different ids &actions as params to same function like so
function on() {
document.getElementById("overlay").style.display = "block";
}
function on1() {
document.getElementById("overlay1").style.display = "block";
}
function off() {
document.getElementById("overlay").style.display = "none";
}
function toggle(id, value) {
document.getElementById(id).style.display = value;
}
.img {
transition: transform 5s ease-in-out;
transform: scale(1);
transform-origin: 0 0;
}
.img:hover {
transform: scale(1.25)
}
#overlay,
#overlay1 {
position: fixed;
display: none;
width: 100%;
height: 100%;
top: 0;
left: 0;
right: 0;
bottom: 0;
background-color: white;
z-index: 77777772;
cursor: pointer;
}
#text,
#text1 {
position: fixed;
top: 20%;
left: 5%;
font-size: 50px;
color: black;
transform: translate(-50% -50%);
-ms-transform: translate(-50% -50%);
}
<div id="overlay" onclick="toggle('overlay', 'none')">
<div id="text">
<div style="width: 48%; float:left">
<h2>XXX</h2>
<h4>ZZZ</h4>
<p style="font-size:14px;">
Help bring forth the immense talent that resides amongst the valley’s citizens. </p>
</div>
<div style="width: 50%; float:right; margin-top:-220px;
">
<img class="img" style="height:100%" src="http://cdn.dpmag.com/2016/06/boydB3_6881-683x1024.jpg">
</div>
</div>
<div style="padding:20px">
<h2></h2>
<a onclick="toggle('overlay', 'block')"></a>
</div>
<div id="overlay1" onclick="toggle('overlay1', 'block')">
<div id="text1">
<div style="width: 48%; float:left">
<h2>AAA</h2>
<h4>MMM</h4>
<p style="font-size:14px;">Help bring forth the immense talent that resides amongst the valley’s citizens. </p>
</div>
<div style="width: 50%; float:right; margin-top:-220px;
">
<img class="img" style="height:100%" src="http://cdn.dpmag.com/2016/06/002boydB37683-703x1024.jpg">
</div>
</div>
<div style="padding:20px">
<h2></h2>
<a onclick="toggle('overlay1', 'block')"></a>
</div>
</div>
</div>
<a onclick="toggle('overlay', 'block')" style="font-size: 11pt;">Read More -></a>
<a onclick="toggle('overlay', 'block')" style="font-size: 11pt;">Read More -></a> 1. List item

Content Slider Pure CSS

I have code below for a content slider using HTML, CSS and JQuery. Is it possible to get exactly what I have now but using pure CSS only? If its not possible with pure CSS is it possible to do with Vanilla JavaScript with no JQuery? Anything helps, cheers.
$(function(){
var scroller = $('#scroller div.innerScrollArea');
var scrollerContent = scroller.children('ul');
scrollerContent.children().clone().appendTo(scrollerContent);
var curX = 0;
scrollerContent.children().each(function(){
var $this = $(this);
$this.css('left', curX);
curX += $this.outerWidth(true);
});
var fullW = curX / 2;
var viewportW = scroller.width();
// Scrolling speed management
var controller = {curSpeed:0, fullSpeed:2};
var $controller = $(controller);
var tweenToNewSpeed = function(newSpeed, duration)
{
if (duration === undefined)
duration = 600;
$controller.stop(true).animate({curSpeed:newSpeed}, duration);
};
// Pause on hover
scroller.hover(function(){
tweenToNewSpeed(0);
}, function(){
tweenToNewSpeed(controller.fullSpeed);
});
// Scrolling management; start the automatical scrolling
var doScroll = function()
{
var curX = scroller.scrollLeft();
var newX = curX + controller.curSpeed;
if (newX > fullW*2 - viewportW)
newX -= fullW;
scroller.scrollLeft(newX);
};
setInterval(doScroll, 40);
tweenToNewSpeed(controller.fullSpeed);
});
#scroller {
position: absolute;
}
#scroller .innerScrollArea {
overflow: hidden;
position: absolute;
top: 0;
bottom: 0;
left: 0;
right: 0;
}
#scroller ul {
padding: 0;
position: relative;
}
#scroller li {
padding: 0;
list-style-type: none;
position: absolute;
}
.circle {
width: 250px;
height: 250px;
position: relative;
margin: auto;
left: 0;
right: 0;
top: 0;
bottom: 0;
border-radius: 50%;
background-color:transparent;
border-style:solid;
border-width:9px;
border-color:#006850;
}
.circle-text {
color: #1f497d;
font-family:Verdana;
font-size: 20.5px;
text-align: center;
width: 200px;
top: 90px;
left: 10%;
bottom: 0;
position: absolute;
z-index: 99;
}
.arrow {
width:300px;
height:80px;
}
.flipimage {
width:300px;
height:80px;
-moz-transform: scaleY(-1);
-webkit-transform: scaleY(-1);
-o-transform: scaleY(-1);
transform: scaleY(-1);
-ms-filter: fliph; /*IE*/
filter: fliph; /*IE*/
}
.everything {
/*transform: scale(0.6);
}
<div class="everything">
<div id="scroller" style="width: 900px; height: 470px; margin: 0 auto;">
<div class="innerScrollArea">
<ul>
<li>
<br style="line-height:89px;"/>
<div class="circle">
<div class="circle-text">
HR Connect<br/>Service<br/>Representative
</div>
</div>
<img class="flipimage" src="http://res.cloudinary.com/djxai1v1e/image/upload/v1499182382/testarrow_png6fn.png">
</li>
<li>
<img class="arrow" src="http://res.cloudinary.com/djxai1v1e/image/upload/v1499182382/testarrow_png6fn.png">
<div class="circle">
<div class="circle-text">
Employee<br/>Relations<br/>Specialist
</div>
</div>
</li>
<li>
<br style="line-height:89px;"/>
<div class="circle">
<div class="circle-text">
Employee<br/>Relations<br/>Manager
</div>
</div>
<img class="flipimage" src="http://res.cloudinary.com/djxai1v1e/image/upload/v1499182382/testarrow_png6fn.png">
</li>
<li>
<img class="arrow" src="http://res.cloudinary.com/djxai1v1e/image/upload/v1499182382/testarrow_png6fn.png">
<div class="circle">
<div class="circle-text">
Director, Employee<br/>Relations &<br/>Well-Being
</div>
</div>
</li>
</ul>
</div>
</div>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
</div>
You may use animation , but to keep the whole thing sliding for ever, you will need to clone (or make a redundant copy in HTML) at least of the elements that you see at first in the slider . Else, it would behave as a marquee , living a blank space untill everything slides off the box.
Example below:
/* all position:absolute removed */
#scroller {
overflow:hidden;
}
#scroller .innerScrollArea {
}
#scroller ul {
padding: 0;
position: relative;
display:flex;/* UPDATE */
}
#scroller li {
padding: 0;
list-style-type: none;
}
.circle {
width: 250px;
height: 250px;
position: relative;
margin: auto;
left: 0;
right: 0;
top: 0;
bottom: 0;
border-radius: 50%;
background-color:transparent;
border-style:solid;
border-width:9px;
border-color:#006850;
}
.circle-text {
color: #1f497d;
font-family:Verdana;
font-size: 20.5px;
text-align: center;
width: 200px;
top: 90px;
left: 10%;
bottom: 0;
position: absolute;
z-index: 99;
}
.arrow {
width:300px;
height:80px;
}
.flipimage {
width:300px;
height:80px;
-moz-transform: scaleY(-1);
-webkit-transform: scaleY(-1);
-o-transform: scaleY(-1);
transform: scaleY(-1);
-ms-filter: fliph; /*IE*/
filter: fliph; /*IE*/
}
/* UPDATE for animation */
ul {
animation: slidli 9s infinite linear;
}
ul:hover {
animation-play-state:paused;
}
#keyframes slidli {
100% {
transform:translatex(-133.5%);/* this is to be update to the content with to see every element slide once untill copies/clone comes back at same spot */
}
}
<div class="everything">
<div id="scroller" style="width: 900px; height: 470px; margin: 0 auto;">
<div class="innerScrollArea">
<ul>
<li>
<br style="line-height:89px;" />
<div class="circle">
<div class="circle-text">
HR Connect<br/>Service<br/>Representative
</div>
</div>
<img class="flipimage" src="http://res.cloudinary.com/djxai1v1e/image/upload/v1499182382/testarrow_png6fn.png">
</li>
<li>
<img class="arrow" src="http://res.cloudinary.com/djxai1v1e/image/upload/v1499182382/testarrow_png6fn.png">
<div class="circle">
<div class="circle-text">
Employee<br/>Relations<br/>Specialist
</div>
</div>
</li>
<li>
<br style="line-height:89px;" />
<div class="circle">
<div class="circle-text">
Employee<br/>Relations<br/>Manager
</div>
</div>
<img class="flipimage" src="http://res.cloudinary.com/djxai1v1e/image/upload/v1499182382/testarrow_png6fn.png">
</li>
<li>
<img class="arrow" src="http://res.cloudinary.com/djxai1v1e/image/upload/v1499182382/testarrow_png6fn.png">
<div class="circle">
<div class="circle-text">
Director, Employee<br/>Relations &<br/>Well-Being
</div>
</div>
</li>
<!-- from here it is a copy of the previous elements . 3 of them might have been enough -->
<li>
<br style="line-height:89px;" />
<div class="circle">
<div class="circle-text">
HR Connect<br/>Service<br/>Representative
</div>
</div>
<img class="flipimage" src="http://res.cloudinary.com/djxai1v1e/image/upload/v1499182382/testarrow_png6fn.png">
</li>
<li>
<img class="arrow" src="http://res.cloudinary.com/djxai1v1e/image/upload/v1499182382/testarrow_png6fn.png">
<div class="circle">
<div class="circle-text">
Employee<br/>Relations<br/>Specialist
</div>
</div>
</li>
<li>
<br style="line-height:89px;" />
<div class="circle">
<div class="circle-text">
Employee<br/>Relations<br/>Manager
</div>
</div>
<img class="flipimage" src="http://res.cloudinary.com/djxai1v1e/image/upload/v1499182382/testarrow_png6fn.png">
</li>
<li>
<img class="arrow" src="http://res.cloudinary.com/djxai1v1e/image/upload/v1499182382/testarrow_png6fn.png">
<div class="circle">
<div class="circle-text">
Director, Employee<br/>Relations &<br/>Well-Being
</div>
</div>
</li>
</ul>
</div>
</div>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
</div>
Notice: I used the flex model and droppped the absolute positionning. Main parent can be in absolute if you do need it, children do not.

Not able to fetch inline transform scale using jquery

I am creating a functionality wherein I need to fetch the inline transform scale value from each li.
Below I have created a demo for you to help me out?
HTML
<div style="color:red;transform:scale(1);">Dummy content</div>
JS
$(function(){
$('div').click(function(){
var trans=$('div').css('transform');
console.log(trans);
});
});
Thanks in advance!
--------------------Update------------------------
I think my question didnt justify to the problem currently I am facing so please check the below codepen for the reference.
http://codepen.io/anon/pen/vOzoWv
Below is the code available who might not be able to check in codepen:
HTML
<ul>
<li class="image-container">
<img src="http://a3.mzstatic.com/us/r30/Purple7/v4/2e/71/0f/2e710fc0-54c2-ce6a-3ce6-296cc0fe526e/icon175x175.png" alt="Receipt" style="transform: scale(0.55); margin-top: -100px;">
</li>
<li class="image-container">
<img src="http://a3.mzstatic.com/us/r30/Purple7/v4/2e/71/0f/2e710fc0-54c2-ce6a-3ce6-296cc0fe526e/icon175x175.png" alt="Receipt" style="transform: scale(0.6); margin-top: -80px;">
</li>
<li class="image-container">
<img src="http://a3.mzstatic.com/us/r30/Purple7/v4/2e/71/0f/2e710fc0-54c2-ce6a-3ce6-296cc0fe526e/icon175x175.png" alt="Receipt" style="transform: scale(0.7); margin-top: -40px;">
</li>
<li class="image-container">
<img src="http://a3.mzstatic.com/us/r30/Purple7/v4/2e/71/0f/2e710fc0-54c2-ce6a-3ce6-296cc0fe526e/icon175x175.png" alt="Receipt" style="transform: scale(0.8); margin-top: 1px;">
</li>
<li class="image-container">
<img src="http://a3.mzstatic.com/us/r30/Purple7/v4/2e/71/0f/2e710fc0-54c2-ce6a-3ce6-296cc0fe526e/icon175x175.png" alt="Receipt" style="transform: scale(0.9); margin-top: 50px;">
</li>
<li class="image-container">
<img src="static/images/fileeebox/Receipt.jpg" alt="Receipt" style="transform: scale(1); margin-top: 100px;">
</li>
<li class="image-container">
<img src="static/images/fileeebox/Receipt.jpg" alt="Receipt" style="transform: scale(1.1); margin-top: 200px;">
</li>
<li class="image-container" style="display: none;">
<img src="http://a3.mzstatic.com/us/r30/Purple7/v4/2e/71/0f/2e710fc0-54c2-ce6a-3ce6-296cc0fe526e/icon175x175.png" alt="Receipt" style="transform: scale(1.1); margin-top: 200px;">
</li>
<li class="image-container" style="display: none;">
<img src="http://a3.mzstatic.com/us/r30/Purple7/v4/2e/71/0f/2e710fc0-54c2-ce6a-3ce6-296cc0fe526e/icon175x175.png" alt="Receipt" style="transform: scale(1.2); margin-top: 700px;">
</li>
<li class="image-container" style="display: none;">
<img src="http://a3.mzstatic.com/us/r30/Purple7/v4/2e/71/0f/2e710fc0-54c2-ce6a-3ce6-296cc0fe526e/icon175x175.png" alt="Receipt">
</li>
</ul>
CSS:
ul li.image-container img {
max-width: 100%;
max-height: 100%;
margin: 0 auto;
box-shadow: 0 0 25px rgba(0, 0, 0, 0.4);
transition: all 600ms ease-in-out;
list-item-style:none;
}
ul li.image-container:last-child img {
transform: scale(1.2);
margin-top: 700px;
}
ul li.image-container:nth-last-child(2) img {
transform: scale(1.1);
margin-top: 200px;
}
ul li.image-container:nth-last-child(3) img {
transform: scale(1);
margin-top: 100px;
}
ul li.image-container:nth-last-child(4) img {
transform: scale(0.9);
margin-top: 50px;
}
ul li.image-container:nth-last-child(5) img {
transform: scale(0.8);
margin-top: 1px;
}
ul li.image-container:nth-last-child(6) img {
transform: scale(0.7);
margin-top: -40px;
}
ul li.image-container:nth-last-child(7) img {
transform: scale(0.6);
margin-top: -80px;
}
ul li.image-container:nth-last-child(8) img {
transform: scale(0.55);
margin-top: -100px;
}
ul li.image-container:nth-last-child(9) img {
transform: scale(0.5);
margin-top: -120px;
}
ul li.image-container:nth-last-child(10) img {
transform: scale(0.45);
margin-top: -140px;
}
ul li.image-container:nth-last-child(n+10) img {
transform: scale(0.4);
margin-top: -155px;
}
JS
$(function(){
$('img').click(function(){
var arrImages=$('li.image-container');
var length=arrImages.length;
var lastElement=$(arrImages).find(':visible').last();
var i;
for(i=length-1;i>=0;i--){
var obj=$(arrImages[i]);
var prevMargin=$(obj).eq(i-1).find('img').css('margin-top');
var prevScale=$(obj).eq(i-1).find('img').css('transform');
alert(prevMargin);
alert(prevScale);
}
});
});
-- Update
Ok, since that was not obvious from the info in your previous post i am just putting my update of the answer up here. This should be what you are looking for.
$(function() {
$('img').click(function(){
var arrImages = $('li.image-container');
var length = arrImages.length;
var lastElement = $(arrImages).find(':visible:last');
var i;
for( i = length -1; i >= 0; i-- ) {
var obj = $(arrImages[i]);
if (i < length - 2 && i !== 0) {
var prevMargin = arrImages.eq(i - 1 ).find('img').css('margin-top');
var prevScale = arrImages.eq(i - 1 ).find('img').css('transform');
console.log(prevScale);
}
}
});
});

How to Flip Div's in Randomly

I have created the application where All divs are Flip Vertically on hover. I wanted to make it random without hover. How should I do that?
.vertical.flip-container {
position: relative;
float: left;
margin-left: 50px;
}
.vertical .back {
transform: rotateX(180deg);
}
.vertical.flip-container .flipper {
transform-origin: 100% 50px;
}
.vertical.flip-container:hover .flipper {
transform: rotateX(-180deg);
}
.flip-container {
perspective: 1000;
}
/* flip the pane when hovered */
.flip-container:hover .flipper,
.flip-container.hover .flipper {
transform: rotateY(180deg);
}
.flip-container,
.front,
.back {
width: 100px;
height: 100px;
}
.flipper {
transition: 0.6s;
transform-style: preserve-3d;
position: relative;
}
.front,
.back {
backface-visibility: hidden;
position: absolute;
top: 0;
left: 0;
}
<div class="flip-container vertical" ontouchstart="this.classList.toggle('hover');">
<div class="flipper">
<div class="front" style="background: red">
Rushikesh
</div>
<div class="back" style="background:green">
Jogle
</div>
</div>
</div>
<div class="flip-container vertical" ontouchstart="this.classList.toggle('hover');">
<div class="flipper">
<div class="front" style="background: red">
Rushikesh
</div>
<div class="back" style="background:green">
Jogle
</div>
</div>
</div>
<div class="flip-container vertical" ontouchstart="this.classList.toggle('hover');">
<div class="flipper">
<div class="front" style="background: red">
Rushikesh
</div>
<div class="back" style="background:green">
Jogle
</div>
</div>
</div>
Any suggestions would be thankful.
I simplified your markup and CSS quite a bit. Also gave it a more 3D look.
You can use setInterval to flip them hover:
http://jsfiddle.net/7x75466y/5/
var $flippers = $(".flip-container"),
qtFlippers = $flippers.length;
setInterval(function () {
$flippers.eq(Math.floor(Math.random()*qtFlippers)).toggleClass('hover');
}, 1000);
Here is a JSfiddle that selects a random tile, and applies an action to it at every second (using setTimeout). You can perform whatever action you like on the tile. Using jQuery
http://jsfiddle.net/7x75466y/2/
var containers = $(".flip-container")
setInterval(function() {
var target = containers.eq(Math.floor(Math.random() * containers.size()))
target.fadeToggle() //DO WHAT YOU WANT TO THE TARGET
}, 1000)

Center container divs in different resolutions

I am building portfolio website using bootstraper and isotope js. I have container div. On desktop browser view container contains 3 divs in one line and all looking good, but when resolution changed and number of divs decreased(less than two per line) - in that case the divs are not centered.
<div id="container" class="clearfix isotope" style="position: relative; overflow: hidden; height: 680px;">
<div class="element item col-md-4 isotope-item" style="position: absolute; left: 0px; top: 0px; -webkit-transform: translate(0px, 0px) scale(1, 1); opacity: 1;">
<div class="view view-first">
//content
</div>
</div>
<div class="element item col-md-4 isotope-item" style="position: absolute; left: 0px; top: 0px; -webkit-transform: translate(320px, 0px) scale(1, 1); opacity: 1;">
<div class="view view-first">
//content
</div>
</div>
<div class="element item col-md-4 isotope-item" style="position: absolute; left: 0px; top: 0px; -webkit-transform: translate(640px, 0px) scale(1, 1); opacity: 1;">
<div class="view view-first">
//content
</div>
</div>
<div class="element item col-md-4 isotope-item" style="position: absolute; left: 0px; top: 0px; -webkit-transform: translate(0px, 340px) scale(1, 1); opacity: 1;">
<div class="view view-first">
//content
</div>
</div>
</div>
How do you fix that?
Actually your code is not working or well formed the way it is presented in your question. Is there a stray closing tag </div> in the second <div class="element item col-md-4 isotope-item" ?
I jsfiddled it here and style="position: absolute; left: 0px; top: 0px; will overlap every containers to top left.
If you look at that bootstrap example code, you will notice the specified the behavior of a container for dirrenent viewport size like so :
<div class="col-6 col-sm-6 col-lg-4">
I recommend you to read bootstrap grid-options so you get a better comprehension about how to use it.
Hope this helps

Categories