I have a flip animation on my website. It works on every browser on PC and Android, but does not work on safari. It will flip and you see a flash of the "back" card and then it goes away and you just get a white square. I think I set the -webkit- like it is supposed to be set but for some reason it just isn't working. Does anyone have any ideas?
HTML:
<div class="card">
<div class="face front hover">
<img src="images/pawprints_edit.png" width="300" height="180" alt="sign up for al-van newsletter" id="news-img" class="d-inline-block col-md-12 img-fluid my-5 pt-2" />
<p id="thanks" class="text-center"></p>
</div>
<div class="face back">
<form name="mailForm" class="mail-form" autocomplete="on" novalidate>
<div class="form-group mb-0 px-2">
<label for="name">Name:</label>
<input type="text" class="form-control form-control-sm" id="name" placeholder="John Doe">
</div>
<div class="form-group mb-0 px-2">
<label for="email">Email Address:</label>
<input type="text" class="form-control form-control-sm" id="email" placeholder="yourname#domain.com">
</div>
<div class="form-group mb-0 px-2">
<label for="message">Please type your message:</label>
<textarea class="form-control form-control-sm" id="message" cols="30" rows="4"></textarea>
<input type="button" id="submit" value="Submit">
<input type="button" id="cancel" value="Cancel">
<p id="errorP" class="text-center"></p>
</div>
</form>
</div>
</div>
CSS:
/* form animation */
.scene {
width: 100%;
height: 300px!important;
perspective: 1000px;
-webkit-perspective: 1000px;
border: none;
}
.card {
width: 100%;
height: 100%;
position: relative;
-webkit-transition: -webkit-transform 1s;
transition: transform 1s;
-webkit-transform-style: preserve-3d;
transform-style: preserve-3d;
border: none;
}
.face {
position: absolute;
height: 100%;
width: 100%;
-webkit-backface-visibility: hidden;
backface-visibility: hidden;
}
.front {
background: #98b98a;;
-webkit-z-index: -1;
z-index: -1
}
.front.hover {
background: #98b98a;
-webkit-z-index: 2;
z-index: 2;
}
.back {
background: #4c87a9;
-webkit-transform: rotateY(180deg);
transform: rotateY(180deg);
-webkit-z-index: 1;
z-index: 1;
}
.back [type=text]:hover {
cursor: text!important;
}
.card.is-flipped {
-webkit-transform: rotateY(180deg);
transform: rotateY(180deg);
}
.hover:hover {
cursor: pointer;
}
/* End animation */
and JS:
/* flip animation script */
function flip()
{
'use strict';
console.log("Flip is being triggered");
var card = document.querySelector(".card");
var face = document.querySelector(".front");
var name = document.getElementById("name");
var email = document.getElementById("email");
var errorP = document.getElementById("errorP");
if(card.removeEventListener)
{card.removeEventListener("click", flip, false);}
else if(card.detachEvent)
{card.detachEvent("onclick", flip);}
card.classList.toggle("is-flipped");
face.classList.toggle("hover");
name.style.background = "#fff";
email.style.background = "#fff";
errorP.style.display = "none";
}
/* Function to flip the card back over when canceled */
function cancelFlip()
{
'use strict';
console.log("Cancel has been activated");
var card = document.querySelector(".card");
var face = document.querySelector(".front");
card.classList.toggle("is-flipped");
face.classList.toggle("hover");
setTimeout(function(){if(card.addEventListener){card.addEventListener("click",flip,false);}else if(card.attachEvent){card.attachEvent("onclick",flip);}console.log("setTimeout was triggered");}, 500);
}
I am using a Boostrap 3 framework. JS is custom and CSS was taken from an online tutorial. The link to the site is: http://www.al-van.org/jake I'm developing on a windows platform and don't have an iPhone to test so I'm having my step-dad check it on his iPhone when I make changes. So far, nothing has been working.
UPDATE: it seems like the form is there, I'm able to click things and input text, but you cant actually see anything. It appears as a white square and nothing is visible. I moved the backface-visibility from .face to each .front and .back to see if that would make a difference. It seems it did not.
I found the issue. It seems that the .card class had a default background color which made the entire form white, washing out all of its components when flipped. When I removed this default background color and made it transparent. The issue was resolved.
add backface visibility to your class - .card.is-flipped, because you are using transform on that too
Related
i want to move an img by button click. I know this question has been asked a lot, but i couldnt use them.
Heres the relevant HTML:
<button class="ggE" (click)="gegenEnemy(chosenHero, actualEnemy);moveFist(); ...
<div class="col">
<img id="img" class="fist" src="...">
This is the function (typescript):
moveFist(): void {
document.getElementById('img').classList.add('fist');
}
And my css, which makes the picture move from left to right:
.fist {
width: 70px;
height: 70px;
position: relative;
animation-name: example;
animation-duration: 2s;
}
#keyframes example {
0% {left:50px; top:20px;}
100% {left:450px; top:20px;}
}
So why cant i connect it with a button click?
First of all validate your HTML code
<button class="ggE" onclick="moveFist();">button</button>
<div class="col">
<img id="img" class="" src="https://via.placeholder.com/150">
<div>
Edits:
function moveFist(){
document.getElementById("img").classList.remove("fist");
// element.offsetWidth = element.offsetWidth;
// Do this instead:
void img.offsetWidth;
document.getElementById("img").classList.add("fist");
}
set the width of img by it's offset width that is,
img.offsetWidth;
Can you something like this ?
function moveFist(){
document.getElementById("img").classList.remove("fist");
// element.offsetWidth = element.offsetWidth;
// Do this instead:
void img.offsetWidth;
document.getElementById("img").classList.add("fist");
}
img{
width: 70px;
height: 70px;
position: relative;
left:50px;
animation-duration: 2s;
top:20px;
}
.fist{
position:relative;
animation-name: example;
}
#keyframes example {
0% {left:50px; top:20px;}
100% {left:450px; top:20px;}
}
<button class="ggE" onclick="moveFist()">button</button>
<div class="col">
<img id="img" class="" src="https://via.placeholder.com/150">
<div>
I am using a fairly nice zoom-in / zoom-out effect using only CSS and HTML. The issue I am having is that if a user zooms in on two images, both images will be enlarged on the page. This is technically what it should do, however I am wondering how I can disable this effect.
This is what I am looking for: e.g. there are two images on a page. If I zoom in one one image and then zoom in on the other image (while the first image is zoomed), the first image should zoom out to allow the second image to be the only zoomed image on the page. This principle would apply if there were, for example, ten images -- only one image can be zoomed at any time.
input[type=checkbox] {
display: none;
}
.container img {
width: 100%;
transition: transform 0.25s ease;
cursor: zoom-in;
}
input[type=checkbox]:checked ~ label > img {
transform: scale(2.5);
cursor: zoom-out;
}
<div class="container">
<input type="checkbox" id="zoomCheck1">
<label for="zoomCheck1">
<img src="https://www.vintagevelo.co.uk/wp-content/uploads/2018/02/DSC_0040-768x512.jpg" />
</label>
</div>
<div class="container">
<input type="checkbox" id="zoomCheck2">
<label for="zoomCheck2">
<img src="https://premium-cycling.com/wp-content/uploads/2018/05/FAGGIN-Campione-del-mondo-1980s-frameset-7.jpg" />
</label>
</div>
Use the + single next selector instead of next all
Note: I recommend using more specific class selectors of some sort, so that these styles don't end up affecting other elements unintentionally, and make the styles more reusable.
Switched to radio elements to only allow one to be checked at a time. Use "name" to group them. You can also use name attribute for the selectors.
document.querySelector('.container').addEventListener('click', e => {
if (e.target.matches('input[type=radio] + label > img')) {
e.target.parentNode.previousSibling.previousSibling.checked = !e.target.parentNode.previousSibling.previousSibling.checked;
e.preventDefault();
}
});
input[type=radio] {
display: none;
}
.container img {
width: 100%;
transition: transform 0.25s ease;
cursor: zoom-in;
}
input[type=radio]:checked+label>img {
transform: scale(2.5);
cursor: zoom-out;
}
img {
width: 50px!important;
height: 50px;
}
<div class="container">
<input type="radio" name="zooms" id="zoomCheck1">
<label for="zoomCheck1">
<img class="center round-corner"
src="https://i.imgur.com/8qmxbHT.jpeg" />
</label>
<input type="radio" name="zooms" id="zoomCheck2">
<label for="zoomCheck2">
<img class="center round-corner"
src="https://i.imgur.com/8qmxbHT.jpeg" />
</label>
</div>
I am developing a web application using Material Design Lite.
One of the requirements is this: A sidebar exists such that by default, it will display the icons of the menu items at a smaller width (say 50px). Clicking on the menu (hamburger) icon then expands the drawer to a larger size and shows not only the icons but the text beside them. Here is an example of what I want to achieve:
Default:
Expand:
Here is my current HTML:
<body>
<!-- Always shows a header, even in smaller screens. -->
<div class="mdl-layout mdl-js-layout mdl-layout--fixed-drawer mdl-layout--fixed-header">
<header class="mdl-layout__header">
<div class="mdl-layout__header-row">
<button class="mdl-button mdl-js-button mdl-button--icon">
<i class="material-icons">menu</i>
</button>
<!-- Add spacer, to align navigation to the right -->
<div class="mdl-layout-spacer"></div>
<!-- Navigation. We hide it in small screens. -->
<button class="mdl-button mdl-js-button mdl-button--icon">
<i class="material-icons">apps</i>
</button>
</div>
</header>
<div class="mdl-layout__drawer">
<span class="mdl-layout-title"></span>
<nav class="mdl-navigation">
<a class="mdl-navigation__link" href="">
<i class="material-icons md-dark">account_circle</i>
<span>Account</span>
</a>
<a class="mdl-navigation__link" href="">
<i class="material-icons md-dark">home</i>
<span>Home</span>
</a>
<a class="mdl-navigation__link" href="">
<i class="material-icons md-dark">assignment</i>
<span>Reports</span>
</a>
<a class="mdl-navigation__link" href="">
<i class="material-icons md-dark">input</i>
<span>Logout</span>
</a>
</nav>
</div>
<main class="mdl-layout__content">
<div class="page-content">
<!-- Your content goes here -->
#RenderBody()
</div>
</main>
</div>
</body>
Is there a good/correct way of doing this? I was wondering how this could be done and haven't come up with a good solution.
Have a look at this answer. I think it's a good approach to achieving this effect.
You can then just drop the polyfill in and write in your CSS something like:
.mdl-navigation .material-icons {
opacity: 0;
transition: 250ms opacity ease-in-out;
}
.mdl-navigation[min-width~="200px"] .material-icons {
opacity: 1;
}
If you think a polyfill is too much to add just this functionality I can think of one other way that doesn't use any javascript, but it wouldn't be as flexible with regards to how you animate the showing/hiding should you want to animate it. It involves overlapping the main content area over the drawer. Give me a moment and I'll mock up a demo.
EDIT
Here's what I was thinking as far as a non-js approach (still requires some for the toggling of the is-expanded class): https://jsfiddle.net/damo_s/27u4huzf/2/
.mdl-layout__drawer {
transform: translateX(0);
z-index: 1;
box-shadow: none;
border-right: 0;
&.is-expanded {
+ .mdl-layout__header {
margin-left: 240px!important;
&:before {
width: 0;
left: 200px;
}
}
~ .mdl-layout__content {
margin-left: 240px!important;
&:before {
width: 0;
left: 200px;
}
}
}
}
.mdl-layout__header,
.mdl-layout__content {
margin-left: 55px!important;
}
.mdl-layout__header {
z-index: 2;
&:before {
background: #fff;
content: '';
display: block;
position: absolute;
width: 15px;
height: 100%;
left: 40px;
}
}
.mdl-layout__header-row {
padding: 0 16px 0 22px;
}
.mdl-layout__content {
background: #878787;
}
.mdl-layout__drawer-button {
display: none;
}
.mdl-layout__drawer .mdl-navigation .mdl-navigation__link:hover {
background-color: transparent;
}
On looking at it now, I don't think it's a very good approach (for a number of reasons you might notice playing around with it), but I'll leave it here just in case anyone wishes to improve upon it.
EDIT 2
I modified the previous demo to simplify it and allow for opening/closing animation. I don't know if at this point you'd exactly be doing things the "Material" way but I think it's workable and better anyway than my previous attempt. Demo: https://jsfiddle.net/damo_s/Ln6e4qLt/
.mdl-layout__drawer {
overflow: hidden;
width: 55px;
transform: translateX(0);
transition: 250ms width ease-in-out;
.mdl-navigation__link span {
opacity: 0;
transition: 250ms opacity ease-in-out;
}
+ .mdl-layout__header,
~ .mdl-layout__content {
transition: 250ms margin-left ease-in-out;
}
&.is-expanded {
width: 240px;
.mdl-navigation__link span {
opacity: 1;
}
+ .mdl-layout__header,
~ .mdl-layout__content{
margin-left: 240px!important;
}
}
}
.mdl-layout__header,
.mdl-layout__content {
margin-left: 55px!important;
}
.mdl-navigation {
width: 240px;
}
.mdl-layout__header-row {
padding: 0 16px 0 22px;
}
.mdl-layout__content {
background: #878787;
}
.mdl-layout__drawer-button {
display: none;
}
This cannot be done by pure CSS. You have have to use jQuery. Something like this
$('#hamburger-button').on('click',function() {
$('#menu .links').css('display','block');
});
Assuming you have hidden links by display:none.
If you can post here your css and html code I can help with specific example.
Wondering if its possible to change the size of checkbox as it's possible with buttons. I want it to be bigger, so it makes it easy to press. Right now its looking like this:
Code:
<div class="form-group">
<label class="col-md-7 control-label">Kalsiumklorid: </label>
<div class="col-md-5" >
{{ Form::checkbox('O_Kals_Klor', 1 , array('class' => 'form-control' )) }}
</div>
</div>
Or you can style it with pixels.
.big-checkbox {width: 30px; height: 30px;}
input[type=checkbox]
{
/* Double-sized Checkboxes */
-ms-transform: scale(2); /* IE */
-moz-transform: scale(2); /* FF */
-webkit-transform: scale(2); /* Safari and Chrome */
-o-transform: scale(2); /* Opera */
padding: 10px;
}
It is possible in css, but not for all the browsers.
The effect on all browsers:
http://www.456bereastreet.com/lab/form_controls/checkboxes/
A possibility is a custom checkbox with javascript:
http://ryanfait.com/resources/custom-checkboxes-and-radio-buttons/
Following works in bootstrap 4 and displays well in CSS, mobile and has no issues with label spacing.
CSS
.checkbox-lg .custom-control-label::before,
.checkbox-lg .custom-control-label::after {
top: .8rem;
width: 1.55rem;
height: 1.55rem;
}
.checkbox-lg .custom-control-label {
padding-top: 13px;
padding-left: 6px;
}
.checkbox-xl .custom-control-label::before,
.checkbox-xl .custom-control-label::after {
top: 1.2rem;
width: 1.85rem;
height: 1.85rem;
}
.checkbox-xl .custom-control-label {
padding-top: 23px;
padding-left: 10px;
}
HTML
<div class="custom-control custom-checkbox checkbox-lg">
<input type="checkbox" class="custom-control-input" id="checkbox-3">
<label class="custom-control-label" for="checkbox-3">Large checkbox</label>
</div>
You can also make it extra large by declaring checkbox-xl
If anyone from BS team is reading this, it would be really good if you make this available right out of the box, I don't see anything for it in BS 5 either
source
It is possible to implement custom bootstrap checkbox for the most popular browsers nowadays.
You can check my Bootstrap-Checkbox project in GitHub, which contains simple .less file.
There is a good article in MDN describing some techniques, where the two major are:
Label redirects a click event.
Label can redirect a click event to its target if it has the for attribute like in <label for="target_id">Text</label> <input id="target_id" type="checkbox" />, or if it contains input as in Bootstrap case: <label><input type="checkbox" />Text</label>.
It means that it is possible to place a label in one corner of the browser, click on it, and then the label will redirect click event to the checkbox located in other corner producing check/uncheck action for the checkbox.
We can hide original checkbox visually, but make it is still working and taking click event from the label. In the label itself we can emulate checkbox with a tag or pseudo-element :before :after.
General non supported tag for old browsers
Some old browsers does not support several CSS features like selecting siblings p+p or specific search input[type=checkbox]. According to the MDN article browsers that support these features also support :root CSS selector, while others not. The :root selector just selects the root element of a document, which is html in a HTML page. Thus it is possible to use :root for a fallback to old browsers and original checkboxes.
Final code snippet:
:root {
/* larger checkbox */
}
:root label.checkbox-bootstrap input[type=checkbox] {
/* hide original check box */
opacity: 0;
position: absolute;
/* find the nearest span with checkbox-placeholder class and draw custom checkbox */
/* draw checkmark before the span placeholder when original hidden input is checked */
/* disabled checkbox style */
/* disabled and checked checkbox style */
/* when the checkbox is focused with tab key show dots arround */
}
:root label.checkbox-bootstrap input[type=checkbox] + span.checkbox-placeholder {
width: 14px;
height: 14px;
border: 1px solid;
border-radius: 3px;
/*checkbox border color*/
border-color: #737373;
display: inline-block;
cursor: pointer;
margin: 0 7px 0 -20px;
vertical-align: middle;
text-align: center;
}
:root label.checkbox-bootstrap input[type=checkbox]:checked + span.checkbox-placeholder {
background: #0ccce4;
}
:root label.checkbox-bootstrap input[type=checkbox]:checked + span.checkbox-placeholder:before {
display: inline-block;
position: relative;
vertical-align: text-top;
width: 5px;
height: 9px;
/*checkmark arrow color*/
border: solid white;
border-width: 0 2px 2px 0;
/*can be done with post css autoprefixer*/
-webkit-transform: rotate(45deg);
-moz-transform: rotate(45deg);
-ms-transform: rotate(45deg);
-o-transform: rotate(45deg);
transform: rotate(45deg);
content: "";
}
:root label.checkbox-bootstrap input[type=checkbox]:disabled + span.checkbox-placeholder {
background: #ececec;
border-color: #c3c2c2;
}
:root label.checkbox-bootstrap input[type=checkbox]:checked:disabled + span.checkbox-placeholder {
background: #d6d6d6;
border-color: #bdbdbd;
}
:root label.checkbox-bootstrap input[type=checkbox]:focus:not(:hover) + span.checkbox-placeholder {
outline: 1px dotted black;
}
:root label.checkbox-bootstrap.checkbox-lg input[type=checkbox] + span.checkbox-placeholder {
width: 26px;
height: 26px;
border: 2px solid;
border-radius: 5px;
/*checkbox border color*/
border-color: #737373;
}
:root label.checkbox-bootstrap.checkbox-lg input[type=checkbox]:checked + span.checkbox-placeholder:before {
width: 9px;
height: 15px;
/*checkmark arrow color*/
border: solid white;
border-width: 0 3px 3px 0;
}
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet"/>
<p>
Original checkboxes:
</p>
<div class="checkbox">
<label class="checkbox-bootstrap">
<input type="checkbox">
<span class="checkbox-placeholder"></span>
Original checkbox
</label>
</div>
<div class="checkbox">
<label class="checkbox-bootstrap">
<input type="checkbox" disabled>
<span class="checkbox-placeholder"></span>
Original checkbox disabled
</label>
</div>
<div class="checkbox">
<label class="checkbox-bootstrap">
<input type="checkbox" checked>
<span class="checkbox-placeholder"></span>
Original checkbox checked
</label>
</div>
<div class="checkbox">
<label class="checkbox-bootstrap">
<input type="checkbox" checked disabled>
<span class="checkbox-placeholder"></span>
Original checkbox checked and disabled
</label>
</div>
<div class="checkbox">
<label class="checkbox-bootstrap checkbox-lg">
<input type="checkbox">
<span class="checkbox-placeholder"></span>
Large checkbox unchecked
</label>
</div>
<br/>
<p>
Inline checkboxes:
</p>
<label class="checkbox-inline checkbox-bootstrap">
<input type="checkbox">
<span class="checkbox-placeholder"></span>
Inline
</label>
<label class="checkbox-inline checkbox-bootstrap">
<input type="checkbox" disabled>
<span class="checkbox-placeholder"></span>
Inline disabled
</label>
<label class="checkbox-inline checkbox-bootstrap">
<input type="checkbox" checked disabled>
<span class="checkbox-placeholder"></span>
Inline checked and disabled
</label>
<label class="checkbox-inline checkbox-bootstrap checkbox-lg">
<input type="checkbox" checked>
<span class="checkbox-placeholder"></span>
Large inline checked
</label>
I used just "save in zoom", in example:
.my_checkbox {
width:5vw;
height:5vh;
}
I have used this library with sucess
http://plugins.krajee.com/checkbox-x
It requires jQuery and bootstrap 3.x
Download the zip here: https://github.com/kartik-v/bootstrap-checkbox-x/zipball/master
Put the contents of the zip in a folder within your project
Pop the needed libs in your header
<link href="http://netdna.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" rel="stylesheet">
<link href="path/to/css/checkbox-x.min.css" media="all" rel="stylesheet" type="text/css" />
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.12.3/jquery.min.js"></script>
<script src="path/to/js/checkbox-x.min.js" type="text/javascript"></script>
Add the data controls to the element using the data-size="xl" to change the size as shown here http://plugins.krajee.com/cbx-sizes-demo
<label for="element_id">CheckME</label>
<input type="checkbox" name="my_element" id="element_id" value="1" data-toggle="checkbox-x" data-three-state="false" data-size="xl"/>
There are numerous other features as well if you browse the plugin site.
<div id="rr-element">
<label for="rr-1">
<input type="checkbox" value="1" id="rr-1" name="rr[]">
Value 1
</label>
</div>
//do this on the css
div label input { margin-right:100px; }
just use simple css
.big-checkbox {width: 1.5rem; height: 1.5rem;top:0.5rem}
Aqui lo que me ayudo a solucionarlo:
.checkbox-xl .form-check-input
{
scale: 2.5;
}
.checkbox-xl .form-check-label
{
padding-left: 25px;
}
<div class="form-check checkbox-xl">
<input class="form-check-input" type="checkbox" value="1" id="checkbox-3" name="check1"/>
<label class="form-check-label" for="checkbox-3">Etiqueta</label>
</div>
Here i am implementing an Image slider
My problem is when i hover my image slider i want to stop my css transition property.
I tried using addclass and removeclass but failed
Here is my code
HTML
<div id="container">
<img src="http://worksheetgenius.com/Next_button.jpg" width="106px;" id="right"/>
<img src="http://worksheetgenius.com/Previous_button.jpg" width="106px;" id="left"/>
<div id="slider">
<div id="slide1" class="slide transition">
<img src="http://s.cghub.com/files/Image/030001-031000/30883/37_max.jpg"/>
</div>
<div id="slide2" class="slide transition">
<img src="http://www.f-16.net/attachments/83_1093_207.jpg" />
</div>
<div id="slide3" class="slide transition">
<img src="http://www.sportbikes.net/forums/attachments/fz6/37654d1111746148-all-fz6-riders-show-us-your-bike-imag0005-edited-downscaled.jpg" />
</div>
<div id="slide4" class="slide transition">
<img src="http://3.bp.blogspot.com/-fpTz_1UegJM/TZ6eQWXTueI/AAAAAAAAASY/TsYJ5xZyixQ/s1600/banner_239.jpg" />
</div>
</div>
</div>
CSS
#slider
{
overflow:hidden;
height:363px;
position:absolute;
left:180px;
top:159px;
padding:0px;
margin:0px;
background: url("header_bg.jpg") repeat-x scroll 0 0 #FFFFFF;
width:1000px;
}
#slide1
{
position:absolute;
left:0px;
z-index:1;
}
.slide
{
position:absolute;
left:1000px;
}
.transition
{
-webkit-transition: all 0.3s;
transition: all 0.3s;
}
.notransition
{
-webkit-transition: none;
transition: none;
}
#right
{
position:absolute;
top: 287.5px;
right: 127px;
z-index: 99;
}
#left
{
position:absolute;
top: 287.5px;
left: 127px;
z-index: 99;
}
Script
var t=setInterval(function(){$("#right").click()},5000);
$(document).ready(function()
{
var present=1;
var next=2;
var total_slide=document.getElementById("slider").childElementCount;
$("#right").click(function()
{
present_slide="#slide"+present;
next_slide="#slide"+next;
$(present_slide).css("left","1000px");
$(next_slide).css("left","0px");
present++;
next++;
if(present==(total_slide+1))
{
present=1;
next=2;
for(i=1;i<=total_slide;i++)
{
$("#slide"+i).css("left","1000px");
}
$("#slide1").css("left","0px");
}
});
$("#left").click(function()
{
if(present==1)
{
next_slide="#slide"+total_slide;
present_slide="#slide"+present;
$(present_slide).css("left","1000px");
$(next_slide).css("left","0px");
present=total_slide;
next=1;
}else
{
next_slide="#slide"+(present-1);
present_slide="#slide"+present;
$(present_slide).css("left","1000px");
$(next_slide).css("left","0px");
present--;
next--;
}
if(next==0)
{
present=(total_slide-1);
next=total_slide;
}
});
$(".slide").on('mouseenter',function()
{ $(this).removeClass('transition').addClass('notransition');});
$(".slide").on('mouseleave',function()
{$(this).removeClass('notransition').addClass('transition');});
});
In the above provided code i used to classes transition and no transition.
I also tried with CSS as follows
.slide:hover
{
-webkit-transition: none;
transition: none;
}
I was doing a similar idea and I ended up using this cycle plugin for jquery Malsup Cycle. I then used this piece of code but you can find all of the options at the link above.
$(document).ready(function(){
$('#slider').cycle({
fx: 'scrollLeft',
speed: 1000,
timeout: 5000,
pause: 1
});
});
Setting the pause flag to one gets your desired functionality where it will stop animating on hover. I hope this helps!
HTML
<div id = "slider">
<div>
Slide 1
</div>
<div>
Slide 2
</div>
<div>
Slide 3
</div>
<div>
Slide 4
</div>
</div>
You just need to link to the plugin in the html and this should provide the desired functionality as I see it. You can put whatever content you want in the divs. I used a picture of our clients' logos with a short description as a banner on our company's page.
EDIT: I changed the selector to match the id that you used. HTML added.