Adding opacity hover transition makes other images flicker - javascript

I have following setup:
$('.home-cat-wrapper a').hover(function() {
var this_left = parseFloat($(this).find('.product-sticker-image').data('left'));
var this_right = parseFloat($(this).find('.product-sticker-image').data('right'));
var left = 0;
var right = 0;
if (this_left > 21) {
left = 2 * (this_left - 21);
} else {
left = 10;
}
if (this_right > 21) {
right = 2 * (this_right - 21);
} else {
right = 10;
}
$(this).find('.product-sticker-image').css({
'top': '0',
'left': left + '%',
'right': right + '%'
});
$(this).find('.home-page-category-hover').stop(true, false).fadeIn(200);
}, function() {
var this_top = $(this).find('.product-sticker-image').data('top');
var this_left = $(this).find('.product-sticker-image').data('left');
var this_right = $(this).find('.product-sticker-image').data('right');
$(this).find('.product-sticker-image').css({
'top': this_top,
'left': this_left,
'right': this_right
});
$(this).find('.home-page-category-hover').stop(true, false).fadeOut(200);
});
.col-xs-12 {
padding-left: 0 !important;
padding-right: 0 !important;
}
.home-page-category-box {
padding: 0 20px;
text-align: center;
margin-bottom: 51px;
}
.home-cat-wrapper {
background-color: #f0f0f0;
}
.home-page-category-heading {
color: #ffffff;
font-size: 13.1px;
font-weight: 600;
background: #000000;
padding: 13px 0 10px;
}
.home-page-image-wrapper {
position: relative;
}
.home-page-category-hover {
position: absolute;
bottom: 0;
right: 0;
left: 0;
display: none;
}
.home-page-category-hover span {
color: #ffffff;
font-size: 12.44px;
background: url("../images/footer-background.jpg");
font-weight: 600;
padding: 13px 0;
display: inline-block;
width: 100%;
-webkit-transition: color 0.2s ease;
-moz-transition: color 0.2s ease;
-ms-transition: color 0.2s ease;
-o-transition: color 0.2s ease;
transition: color 0.2s ease;
}
.category-image-wrapper {
width: 100%;
background: #f0f0f0;
padding: 45px 0 65px;
position: relative;
-webkit-transition: all 0.2s ease;
-moz-transition: all 0.2s ease;
-ms-transition: all 0.2s ease;
-o-transition: all 0.2s ease;
transition: all 0.2s ease;
}
.category-sticker-container {
position: relative;
}
.product-sticker-image {
-webkit-transition: all 0.2s ease;
-moz-transition: all 0.2s ease;
-ms-transition: all 0.2s ease;
-o-transition: all 0.2s ease;
transition: all 0.2s ease;
position: absolute;
}
.category-sticker-container > img {
width: 100%;
-webkit-transition: all 0.2s ease;
-moz-transition: all 0.2s ease;
-ms-transition: all 0.2s ease;
-o-transition: all 0.2s ease;
transition: all 0.2s ease;
}
.product-sticker-image img {
padding: 0;
width: 100%;
}
.home-cat-wrapper a:hover .category-image-wrapper {
background: #ffffff;
}
.home-cat-wrapper a:hover .category-image-wrapper .category-sticker-container > img {
opacity: 0;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script>
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" rel="stylesheet" />
<div class="col-xs-12 home-page-right-container">
<div class="col-sm-3 col-xs-6 home-page-category-box" style="height: 450px;">
<div class="home-cat-wrapper col-xs-12 category-3">
<a href="http://weadmire.dx3webs.com/film.html">
<div class="col-xs-12 home-page-category-heading" style="height: 41px;">Film</div>
<div class="col-xs-12 home-page-image-wrapper">
<div class="col-xs-12 category-image-wrapper">
<div class="col-xs-12 category-sticker-container">
<div class="product-sticker-image" data-top="17%" data-left="21%" data-right="21%" style="top: 17%; left: 21%; right: 21%;">
<img src="http://weadmire.dx3webs.com/pub/media/catalog/product/a/l/alfred-hitchcock.png" alt="Film-artwork">
</div>
<img src="http://weadmire.dx3webs.com/pub/media/catalog/product/cache/1/image/400x/925f46717e92fbc24a8e2d03b22927e1/n/a/natural-white.png" alt="Film">
</div>
</div>
</div>
<div class="home-page-category-hover" style="display: block; opacity: 1;"><span>63 DESIGNS | SEE THEM</span>
</div>
</a>
</div>
</div>
<div class="col-sm-3 col-xs-6 home-page-category-box" style="height: 450px;">
<div class="home-cat-wrapper col-xs-12 category-4">
<a href="http://weadmire.dx3webs.com/design-architecture.html">
<div class="col-xs-12 home-page-category-heading" style="height: 41px;">Design & Architecture</div>
<div class="col-xs-12 home-page-image-wrapper">
<div class="col-xs-12 category-image-wrapper">
<div class="col-xs-12 category-sticker-container">
<div class="product-sticker-image" data-top="17%" data-left="21%" data-right="21%" style="top: 17%; left: 21%; right: 21%;">
<img src="http://weadmire.dx3webs.com/pub/media/catalog/product/a/d/admire-rio.png" alt="Design & Architecture-artwork">
</div>
<img src="http://weadmire.dx3webs.com/pub/media/catalog/product/cache/1/image/400x/925f46717e92fbc24a8e2d03b22927e1/n/a/natural-white.png" alt="Design & Architecture">
</div>
</div>
</div>
<div class="home-page-category-hover" style="display: none; opacity: 1;"><span>17 DESIGNS | SEE THEM</span>
</div>
</a>
</div>
</div>
</div>
When you hover the box you can see there is slight flicker, a blink appears in the t-shirt logo and after that same happens when hover out. I tried with back face visibility and other transform properties but no luck. How can I get rid of this flicker? Thanks.
fiddle

Just add z-index to .product-sticker-image class.
Check the demo

You should use transition: width 0.2s ease; on .category-sticker-container > img in this situation:
.category-sticker-container > img {
width: 100%;
-webkit-transition: width 0.2s ease;
-moz-transition: width 0.2s ease;
-ms-transition: width 0.2s ease;
-o-transition: width 0.2s ease;
transition: width 0.2s ease;
}
JSfiddle here

Related

classList.toggle for several elements Javascript

I designed a vertical slide from bottom navigation on mobile. I would like each tab could move (up or down) with the upper one. May be the toggle method isn't the right one. I use vanilla JS.
Here is my function. The two last lines are to show the idea. I would like to write it in a better way.
let children = document.getElementById('mobile-container').children;
for (let i = 0; i < children.length; i++) {
children[i].addEventListener("touchstart", function () {
children[i].classList.toggle("unfold");
children[i-1].classList.toggle("unfold");
children[i-2].classList.toggle("unfold");
});
}
Here is my HTML
<div id="mobile-container">
<div id="mobile-projets" class="mobile">
<h2>Projets</h2>
</div>
<div id="mobile-expertises" class="mobile">
<h2>Expertises</h2>
</div>
<div id="mobile-clients" class="mobile">
<h2>Clients</h2>
</div>
</div>
Here is my CSS
#mobile-container {
display: block;
position: relative;
width: 100%;
height: 85vh;
top: 15vh;
}
#mobile-projets {
width:100%;
height: 100%;
background: #00A6C6;
text-align: center;
border-radius: 1em 1em 0 0;
position: absolute;
top: 69vh;
}
#mobile-expertises {
width:100%;
height: 95%;
background: #FFFFFF;
color: black;
text-align: center;
border-radius: 1em 1em 0 0;
position: absolute;
top: 74vh;
}
#mobile-clients {
width:100%;
height: 90%;
background: #00A6C6;
text-align: center;
border-radius: 1em 1em 0 0;
position: absolute;
top: 79vh;
}
#mobile-projets.unfold {
top: 0;
transition: all 1s ease;
-webkit-transition: all 1s easeout;
-moz-transition: all 1s easeout;
-ms-transition: all 1s easeout;
-o-transition: all 1s easeout;
}
#mobile-expertises.unfold {
top: 5vh;
transition: all 1s ease;
-webkit-transition: all 1s easeout;
-moz-transition: all 1s easeout;
-ms-transition: all 1s easeout;
-o-transition: all 1s easeout;
}
#mobile-clients.unfold {
top: 10vh;
transition: all 1s ease;
-webkit-transition: all 1s easeout;
-moz-transition: all 1s easeout;
-ms-transition: all 1s easeout;
-o-transition: all 1s easeout;
}

Recreate Adobe Portfolio Dual Hover Effect On Image & Text Block

ive been trying to recreate the hover dual effect that is on https://andreas-demo.myportfolio.com/
However i cant seem to get both to align correctly and then i cannot get the affect that hovers over the entire section but that changes BOTH: 1- Darkening the image, 2 -inversing the colors.
I want to be able to get both affects to happen while hovering over the entire block, just like on the site above^.
Here's my code;
img {
display: block;
width: 60%;
height: 450px;
background-color: #f2f2f2;
!important;
-webkit-filter: brightness(100%);
}
a img:hover {
-webkit-filter: brightness(60%);
-webkit-transition: all 1s ease;
-moz-transition: all 1s ease;
-o-transition: all 1s ease;
-ms-transition: all 1s ease;
transition: all 1s ease;
}
.media {
background-color: #f2f2f2;
!important;
text-align: center;
}
p {
display: inline-block;
vertical-align: middle;
}
<div class="container">
<a href="">
<div class="media">
<img src="img/pexels-photo-733438.jpeg" class="img-fluid" alt="Responsive image">
<p>PROJECT 1</p>
<p>2017</p>
</div>
</a>
</div>
On container:hover, set your container'background-color as black (default to white) and set the image opacity as 0.5.
Move the :hover pseudo-class to one of the 3 parent (wrapper) elements -
.container, .container > a, or .media element. This will have the effect of adding the overlay to both elements on :hover.
Like this:
.container {
font-family: Arial;
}
.container:hover {
-webkit-transition: all 1s ease;
-moz-transition: all 1s ease;
-o-transition: all 1s ease;
-ms-transition: all 1s ease;
transition: all 1s ease;
}
.container__link {
display: flex;
text-decoration: none;
}
.media {
flex: 6;
background-color: #222222;
}
img {
display: block;
width: 100%;
height: 450px;
opacity: 1;
-webkit-transition: all 1s ease;
-moz-transition: all 1s ease;
-o-transition: all 1s ease;
-ms-transition: all 1s ease;
transition: all 1s ease;
}
.container:hover .media img {
opacity: 0.3;
}
.description {
flex: 4;
display: flex;
align-items: center;
justify-content: center;
flex-direction: column;
-moz-transition: all 1s ease;
-o-transition: all 1s ease;
-ms-transition: all 1s ease;
transition: all 1s ease;
background-color: #ffffff;
color: #222222;
}
.container:hover .description {
background-color: #222222;
color: #ffffff;
}
p {
padding: 0;
margin: 0;
}
<div class="container">
<a href="" class="container__link">
<div class="media">
<img src="http://via.placeholder.com/350x150" class="img-fluid" alt="Responsive image">
</div>
<div class="description">
<p>PROJECT 1</p>
<p>2017</p>
</div>
</a>
</div>

Show div when hover over another separate div

I have searched the web and found similar questions to my own, but I have not been able to achieve the results that I am looking for. I am not the most well versed with html/css/and javascript/jquery so I am wondering if it is an error on my part with how I am formatting everything, or the path to which I am trying to write these results.
I have three circles, spaced equally in the center of the page. Each circle links out to a different page. On hovering over a circle, a span is revealed (by changing the opacity property in css) that provides a title for where that link goes.
What I am having trouble doing is: When you hover over each circle, in addition to a span being revealed that provides a title, I want to have a short descriptive text appear below the circles. When you mouse out of that said circle, the descriptive text will disappear. Each circle must have its own descriptor text.
From what I have gathered, the jquery hover on event is likely the best way to do this, however I cannot seem to get the syntax correct to make it work.
<script>
jQuery(document).ready(function() {
jQuery('#text1').hide();
});
jQuery(document).ready(function() {
jQuery('.grid_1').hover(function() {
jQuery(this).find('#text1').show();
},
function() {
jQuery('#text1').hide();
});
});
</script>
Any and all help would be greatly appreciated. Please let me know if I should clarify anything.
Link to jsfiddle
Your jquery references #text1 and it should be .text1 since that element is a class. Also $(this).find('.text').show(); won't work because .text is not a child of the thing you're hovering over ($(this)). Just use $('.text1')
$(document).ready(function() {
$('.text1').hide();
});
$(document).ready(function() {
$('.grid_1').hover(function() {
$('.text1').show();
},
function() {
$('.text1').hide();
});
});
.gridcontainer {
width: 720px;
margin: 30px auto;
}
.grid_1 {
display: inline;
float: left;
margin-left: 10px;
margin-right: 10px;
width: 220px;
}
.grid_2 {
display: inline;
float: left;
margin-left: 10px;
margin-right: 10px;
width: 220px;
}
.grid_3 {
display: inline;
float: left;
margin-left: 10px;
margin-right: 10px;
width: 220px;
}
.fmcircle_out {
width: 200px;
height: 200px;
text-align: center;
display: block;
margin-left: 10px;
opacity: 0.75;
border-radius: 100px;
border: solid 2.5px #8D8B8B;
-moz-border-radius: 100px;
-webkit-border-radius: 100px;
-o-border-radius: 100px;
-webkit-transition: all 0.2s linear;
-moz-transition: all 0.2s linear;
-o-transition: all 0.2s linear;
-ms-transition: all 0.2s linear;
transition: all 0.2s linear;
}
.fmcircle_out:hover {
opacity: 1;
-webkit-transition: all 0.2s linear;
-moz-transition: all 0.2s linear;
-o-transition: all 0.2s linear;
-ms-transition: all 0.2s linear;
transition: all 0.2s linear;
}
.fmcircle_in {
width: 170px;
height: 170px;
margin: 15px;
display: inline-block;
overflow: hidden;
border-radius: 85px;
-moz-border-radius: 85px;
-webkit-border-radius: 85px;
-o-border-radius: 85px;
}
.fmcircle_in img {
border: none;
margin: 30px 25px 25px 25px;
-webkit-transition: all 0.2s linear;
-moz-transition: all 0.2s linear;
-o-transition: all 0.2s linear;
-ms-transition: all 0.2s linear;
transition: all 0.2s linear;
}
.fmcircle_in span {
padding: 0;
border: 0;
vertical-align: baseline;
width: 160px;
background: #fff;
color: #666666;
padding: 5px;
margin: 70px 0 0 0;
height: 20px;
text-align: center;
font-weight: bold;
letter-spacing: 0.08em;
text-transform: uppercase;
position: absolute;
opacity: 0;
border-radius: 2px;
-moz-border-radius: 2px;
-webkit-border-radius: 2px;
-o-border-radius: 2px;
-webkit-transition: all 0.2s linear;
-moz-transition: all 0.2s linear;
-o-transition: all 0.2s linear;
-ms-transition: all 0.2s linear;
transition: all 0.2s linear;
}
.fmcircle_out:hover .fmcircle_in span {
opacity: 1;
-webkit-transition: all 0.2s linear;
-moz-transition: all 0.2s linear;
-o-transition: all 0.2s linear;
-ms-transition: all 0.2s linear;
transition: all 0.2s linear;
}
.fmcircle_out:focus {
opacity: 1;
}
.fmcircle_blue {
background-color: #35C317;
}
.fmcircle_red {
background-color: #BA282B;
}
.fmcircle_green {
background-color: #2E70DC;
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>
<div class="gridcontainer clearfix">
<div class="grid_1">
<div class="fmcircle_out">
<a href="link1.html">
<div class="fmcircle_in fmcircle_blue">
<span>Link 1</span><img src="images/image location1" alt="image1" class="image1" />
</div>
</a>
</div>
</div>
<div class="grid_2">
<div class="fmcircle_out">
<a href="link2.html">
<div class="fmcircle_in fmcircle_green">
<span>Link 2</span><img src="images/image location2" alt="image2" class="image2" />
</div>
</a>
</div>
</div>
<div class="grid_3">
<div class="fmcircle_out">
<a href="link3.html">
<div class="fmcircle_in fmcircle_red">
<span>Link 3</span><img src="images/image location3" alt="image3" class="image3" />
</div>
</a>
</div>
</div>
</div>
<div class="text_container">
<p class="text1">Text box1</p>
<p class="text2">Text box2</p>
<p class="text3">text box3</p>
</div>
Though I would re-write it to be a little more flexible and with less code like this, utilizing a data attribute in the .grid circles to define the text block class to show, then adding/removing a class that shows the text instead of using jquery's $.hide() and $.show()
$(document).ready(function() {
$('.grid').hover(function() {
$($(this).attr('data-text')).addClass('show');
},
function() {
$($(this).attr('data-text')).removeClass('show');
});
});
.gridcontainer {
width: 720px;
margin: 30px auto;
}
.grid_1 {
display: inline;
float: left;
margin-left: 10px;
margin-right: 10px;
width: 220px;
}
.grid_2 {
display: inline;
float: left;
margin-left: 10px;
margin-right: 10px;
width: 220px;
}
.grid_3 {
display: inline;
float: left;
margin-left: 10px;
margin-right: 10px;
width: 220px;
}
.fmcircle_out {
width: 200px;
height: 200px;
text-align: center;
display: block;
margin-left: 10px;
opacity: 0.75;
border-radius: 100px;
border: solid 2.5px #8D8B8B;
-moz-border-radius: 100px;
-webkit-border-radius: 100px;
-o-border-radius: 100px;
-webkit-transition: all 0.2s linear;
-moz-transition: all 0.2s linear;
-o-transition: all 0.2s linear;
-ms-transition: all 0.2s linear;
transition: all 0.2s linear;
}
.fmcircle_out:hover {
opacity: 1;
-webkit-transition: all 0.2s linear;
-moz-transition: all 0.2s linear;
-o-transition: all 0.2s linear;
-ms-transition: all 0.2s linear;
transition: all 0.2s linear;
}
.fmcircle_in {
width: 170px;
height: 170px;
margin: 15px;
display: inline-block;
overflow: hidden;
border-radius: 85px;
-moz-border-radius: 85px;
-webkit-border-radius: 85px;
-o-border-radius: 85px;
}
.fmcircle_in img {
border: none;
margin: 30px 25px 25px 25px;
-webkit-transition: all 0.2s linear;
-moz-transition: all 0.2s linear;
-o-transition: all 0.2s linear;
-ms-transition: all 0.2s linear;
transition: all 0.2s linear;
}
.fmcircle_in span {
padding: 0;
border: 0;
vertical-align: baseline;
width: 160px;
background: #fff;
color: #666666;
padding: 5px;
margin: 70px 0 0 0;
height: 20px;
text-align: center;
font-weight: bold;
letter-spacing: 0.08em;
text-transform: uppercase;
position: absolute;
opacity: 0;
border-radius: 2px;
-moz-border-radius: 2px;
-webkit-border-radius: 2px;
-o-border-radius: 2px;
-webkit-transition: all 0.2s linear;
-moz-transition: all 0.2s linear;
-o-transition: all 0.2s linear;
-ms-transition: all 0.2s linear;
transition: all 0.2s linear;
}
.fmcircle_out:hover .fmcircle_in span {
opacity: 1;
-webkit-transition: all 0.2s linear;
-moz-transition: all 0.2s linear;
-o-transition: all 0.2s linear;
-ms-transition: all 0.2s linear;
transition: all 0.2s linear;
}
.fmcircle_out:focus {
opacity: 1;
}
.fmcircle_blue {
background-color: #35C317;
}
.fmcircle_red {
background-color: #BA282B;
}
.fmcircle_green {
background-color: #2E70DC;
}
.text {
display: none;
}
.show {
display: block;
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>
<div class="gridcontainer clearfix">
<div class="grid_1 grid" data-text=".text1">
<div class="fmcircle_out">
<a href="link1.html">
<div class="fmcircle_in fmcircle_blue">
<span>Link 1</span><img src="images/image location1" alt="image1" class="image1" />
</div>
</a>
</div>
</div>
<div class="grid_2 grid" data-text=".text2">
<div class="fmcircle_out">
<a href="link2.html">
<div class="fmcircle_in fmcircle_green">
<span>Link 2</span><img src="images/image location2" alt="image2" class="image2" />
</div>
</a>
</div>
</div>
<div class="grid_3 grid" data-text=".text3">
<div class="fmcircle_out">
<a href="link3.html">
<div class="fmcircle_in fmcircle_red">
<span>Link 3</span><img src="images/image location3" alt="image3" class="image3" />
</div>
</a>
</div>
</div>
</div>
<div class="text_container">
<p class="text1 text">Text box1</p>
<p class="text2 text">Text box2</p>
<p class="text3 text">text box3</p>
</div>
I'll provide a css solution since there exist a jquery answer
Add the following to your css
.fmcircle_out:hover .description{
opacity:1;
}
.description{
opacity:0;
transition:opacity 1s;
}
.fmcircle_out a{
text-decoration:none;
}
.fmcircle_out:focus {
opacity: 1;
}
See snippet (Note you can add these rules to existing rules declared if you'd like)
.gridcontainer {
width: 720px;
margin: 30px auto;
}
.grid_1 {
display: inline;
float: left;
margin-left: 10px;
margin-right: 10px;
width: 220px;
}
.grid_2 {
display: inline;
float: left;
margin-left: 10px;
margin-right: 10px;
width: 220px;
}
.grid_3 {
display: inline;
float: left;
margin-left: 10px;
margin-right: 10px;
width: 220px;
}
.fmcircle_out {
width: 200px;
height: 200px;
text-align: center;
display: block;
margin-left: 10px;
opacity: 0.75;
border-radius: 100px;
border: solid 2.5px #8D8B8B;
-moz-border-radius: 100px;
-webkit-border-radius: 100px;
-o-border-radius: 100px;
-webkit-transition: all 0.2s linear;
-moz-transition: all 0.2s linear;
-o-transition: all 0.2s linear;
-ms-transition: all 0.2s linear;
transition: all 0.2s linear;
}
.fmcircle_out:hover {
opacity: 1;
-webkit-transition: all 0.2s linear;
-moz-transition: all 0.2s linear;
-o-transition: all 0.2s linear;
-ms-transition: all 0.2s linear;
transition: all 0.2s linear;
}
.fmcircle_in {
width: 170px;
height: 170px;
margin: 15px;
display: inline-block;
overflow: hidden;
border-radius: 85px;
-moz-border-radius: 85px;
-webkit-border-radius: 85px;
-o-border-radius: 85px;
}
.fmcircle_in img {
border: none;
margin: 30px 25px 25px 25px;
-webkit-transition: all 0.2s linear;
-moz-transition: all 0.2s linear;
-o-transition: all 0.2s linear;
-ms-transition: all 0.2s linear;
transition: all 0.2s linear;
}
.fmcircle_in span {
padding: 0;
border: 0;
vertical-align: baseline;
width: 160px;
background: #fff;
color: #666666;
padding: 5px;
margin: 70px 0 0 0;
height: 20px;
text-align: center;
font-weight: bold;
letter-spacing: 0.08em;
text-transform: uppercase;
position: absolute;
opacity: 0;
border-radius: 2px;
-moz-border-radius: 2px;
-webkit-border-radius: 2px;
-o-border-radius: 2px;
-webkit-transition: all 0.2s linear;
-moz-transition: all 0.2s linear;
-o-transition: all 0.2s linear;
-ms-transition: all 0.2s linear;
transition: all 0.2s linear;
}
.fmcircle_out:hover .fmcircle_in span {
opacity: 1;
-webkit-transition: all 0.2s linear;
-moz-transition: all 0.2s linear;
-o-transition: all 0.2s linear;
-ms-transition: all 0.2s linear;
transition: all 0.2s linear;
}
.fmcircle_out:hover .description {
opacity: 1;
}
.description {
opacity: 0;
transition: opacity 1s;
}
.fmcircle_out a {
text-decoration: none;
}
.fmcircle_out:focus {
opacity: 1;
}
.fmcircle_blue {
background-color: #35C317;
}
.fmcircle_red {
background-color: #BA282B;
}
.fmcircle_green {
background-color: #2E70DC;
}
<div class="gridcontainer clearfix">
<div class="grid_1">
<div class="fmcircle_out">
<a href="link1.html">
<div class="fmcircle_in fmcircle_blue">
<span>Link 1</span><img src="images/image location1" alt="image1" class="image1" />
</div>
<div class="description">This link describes option 1</div>
</a>
</div>
</div>
<div class="grid_2">
<div class="fmcircle_out">
<a href="link2.html">
<div class="fmcircle_in fmcircle_green">
<span>Link 2</span><img src="images/image location2" alt="image2" class="image2" />
</div>
<div class="description">This link describes option 2</div>
</a>
</div>
</div>
<div class="grid_3">
<div class="fmcircle_out">
<a href="link3.html">
<div class="fmcircle_in fmcircle_red">
<span>Link 3</span><img src="images/image location3" alt="image3" class="image3" />
</div>
<div class="description">This link describes option 3</div>
</a>
</div>
</div>
</div>
<div class="text_container">
<p class="text1">Text box1</p>
<p class="text2">Text box2</p>
<p class="text3">text box3</p>
</div>
Jquery code Which hide another div on hover and make it visible when mouse move out.
<script>
$(document).ready(function(){
$('.grid_1').hover(
function () {
$('#text1').hide();
},
function () {
$('#text1').show();
}
);
});

Boostrap modal strange issue

I have element with some of the animations made with CSS3. There is a link inside the block which opens modal window, but when the modal window is closed the animation element is left as in "hover" state.
Example in jsfiddle :
<style>
.item-wrap {
position: relative;
height: 200px;
width: 200px;
background-color: black;
overflow: hidden;
}
.item-wrap p {
color: #fff;
text-align: center;
}
.item-wrap::before {
content: ' ';
position: absolute;
left: 0;
top: 0;
width: 0;
height: 100%;
opacity: 0.5;
-webkit-transition: width 0s ease, background-color 0.5s ease;
-moz-transition: width 0s ease, background-color 0.5s ease;
-o-transition: width 0s ease, background-color 0.5s ease;
transition: width 0s ease, background-color 0.5s ease;
}
.item-wrap::after {
content: ' ';
position: absolute;
right: 0;
top: 0;
width: 0;
height: 100%;
opacity: 0.5;
background-color: #fff;
transition: width 0.5s ease;
-webkit-transition: width 0.5s ease;
-moz-transition: width 0.5s ease;
-ms-transition: width 0.5s ease;
-o-transition: width 0.5s ease;
}
.item-wrap:hover::before {
width: 100%;
background-color: #fff;
transition: width 0.5s ease;
-webkit-transition: width 0.5s ease;
-moz-transition: width 0.5s ease;
-ms-transition: width 0.5s ease;
-o-transition: width 0.5s ease;
}
.item-wrap:hover::after {
width: 100%;
background-color: transparent;
transition: all 0s ease;
-webkit-transition: all 0s ease;
-moz-transition: all 0s ease;
-ms-transition: all 0s ease;
-o-transition: all 0s ease;
}
.item-wrap:hover .cover {
bottom: 0;
}
.cover a {
color: #fff;
}
.link1 {
position: absolute;
left: 20px;
top: 50%;
right: 20px;
}
.link2 {
position: absolute;
top: 50%;
right: 20px;
}
.item-wrap .cover {
position: absolute;
right: 0;
left: 0;
bottom: -100%;
width: 100%;
height: 100%;
transition: bottom 0.3s linear;
-webkit-transition: bottom 0.3s linear;
-moz-transition: bottom 0.3s linear;
-ms-transition: bottom 0.3s linear;
-o-transition: bottom 0.3s linear;
z-index: 10;
}
</style>
<div class="item">
<div class="item-wrap">
<p>Main content blah blah</p>
<div class="cover">
Link1
Link2
</div><!-- /.cover -->
</div><!-- /.item-wrap -->
</div><!-- /.item -->
<!-- Modal -->
<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button>
<h4 class="modal-title" id="myModalLabel">Modal title</h4>
</div>
<div class="modal-body">
...
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
<button type="button" class="btn btn-primary">Save changes</button>
</div>
</div>
</div>
</div>
Example ins jsfiddle : https://jsfiddle.net/9objpv9x/
Try to hover to see animation and modal links and then click the "Link1" and close modal to see what happens next.
I just don't know where to start digging.
Actually the "link1" is left at "focus" state and the outline is displayed due to default bootstrap css property:
a:focus {
outline: 5px auto -webkit-focus-ring-color;
outline-offset: -2px;
}
To override it, Modify it in your css.
a#id:focus {
outline: 0px;
}
To remove the focus state after the modal close,
We need to trigger modal in jquery instead of having "data-target" in HTML.
Check out this jsfiddle link.
Updated Code Fix

Sidebar toggled content squeezed

below is my code:
html:
<div id="wrapper" style="background-color:red">
<div id="sidebar-wrapper" style="background-color:yellow">sidebar
<div id="result"></div>
</div>
<div id="header" class="container-fluid">
<div class="navbar">
<a href="#menu-toggle" id="menu-toggle" >Press</a>
<div>This is a serious health setback for me personally, but one of CN's core strengths is that we have a very experienced and tightly-knit senior <span id="counterId"></span></div>
</div>
</div>
css:
#wrapper {
width: 100vw;
padding-left: 0;
-webkit-transition: all 0.5s ease;
-moz-transition: all 0.5s ease;
-o-transition: all 0.5s ease;
transition: all 0.5s ease;
}
#wrapper.toggled {
padding-left: 250px;
}
#sidebar-wrapper {
z-index: 1000;
position: fixed;
left: 250px;
width: 0;
height: 100%;
margin-left: -250px;
overflow-y:auto;
background: #5F657C;
-webkit-transition: all 0.5s ease;
-moz-transition: all 0.5s ease;
-o-transition: all 0.5s ease;
transition: all 0.5s ease;
box-shadow: inset -10px 0px 10px -7px grey;
}
#wrapper.toggled #sidebar-wrapper {
width: 250px;
}
js:
$("#menu-toggle").click(function(e) {
e.preventDefault();
$("#wrapper").toggleClass("toggled");
});
The jsfiddle is below:
JSFIDDLE
My problem is for the left side yellow div, the content inside will kinda squeeze together when the sidebar slide to the left.
I want to make it just hide underneath and don't want the content to be squeezed. Do you guys have any idea?
You could do it like this:
$("#menu-toggle").click(function(e) {
e.preventDefault();
$("#wrapper").toggleClass("toggled");
});
#wrapper {
padding-left: 0;
-webkit-transition: all 0.5s ease;
-moz-transition: all 0.5s ease;
-o-transition: all 0.5s ease;
transition: all 0.5s ease;
}
#wrapper.toggled {
padding-left: 250px;
}
#sidebar-wrapper {
z-index: 1000;
position: fixed;
left: -250px;
width: 250px;
height: 100%;
overflow-y: auto;
background: #050545;
-webkit-transition: all 0.5s ease;
-moz-transition: all 0.5s ease;
-o-transition: all 0.5s ease;
transition: all 0.5s ease;
box-shadow: inset -10px 0px 10px -7px grey;
}
#wrapper.toggled #sidebar-wrapper {
left: 0;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script>
<div id="wrapper" style="background-color:red">
<div id="sidebar-wrapper" style="background-color:yellow">sidebar content show here
<div id="result"></div>
</div>
<div id="header" class="container-fluid">
<div class="navbar">
Press
<div>This is a serious health setback for me personally, but one of CN's core strengths is that we have a very experienced and tightly-knit senior <span id="counterId"></span>
</div>
</div>
</div>
</div>
The width is set default to 250px. In my snippet I'm playing with the offset left to hide/show the sidebar. Study my code and you'll see how it works.

Categories

Resources