CSS3 hover and active problems - css

Trying to make CSS functional map:
CSS
.fader-us {
display: none;
}
.fader-us-content {
display: none;
position: fixed;
top:50px;
left:50px;
z-index:81;
}
.fader-us:active .fader-us-content {
display:block;
}
.fader-us:active .us {
opacity:0;
}
.fader-us-content:hover {
display: block;
}
.fader-us-content:hover .us {
opacity:0;
}
.fader-us img {
line-height: 0;
z-index:79;
-webkit-transition: all 0.3s ease;
-moz-transition: all 0.3s ease;
-o-transition: all 0.3s ease;
-ms-transition: all 0.3s ease;
transition: all 0.3s ease;
}
.us {
position:fixed;
top:33px;
left:55px;
z-index:0;
}
HTML
<div class="fader-us">
<img class ="us" src="us.png" alt="">
<div class="fader-us-content">
<li>California</li>
<li>Florida</li>
</div>
</div>
What im trying to do is make us.png img to disappear when my mouse is over "fader-us-content".
Can't figure out why is the image disappearing only when I keep clicking.
Fiddle
http://jsfiddle.net/r9qHa/

Using '~' may be a good way:
.fader-us-content:hover~.us {
opacity:0;
}
Change the html like this:
<div class="fader-us">
<div class="text">
<p>USAs</p>
</div>
<ul class="fader-us-content">
<li>California</li>
<li>Florida</li>
</ul>
<img class ="us" src="http://s23.postimg.org/rixm8ire3/image.png" alt=""/>
</div>
jsfiddle.net

Try changing this:
<div class="fader-us">
<img class ="us" src="us.png" alt="">
<div class="fader-us-content">
<li>California</li>
<li>Florida</li>
</div>
</div>
.fader-us:active .fader-us-content {
display:block;
}
To This:
<div class="fader-us">
<img class ="us" src="us.png" alt="">
<div class="fader-us-content">
<ul>
<li>California</li>
<li>Florida</li>
</ul>
</div>
</div>
.fader-us:active .fader-us-content:hover {
display:block;
}

Working FIDDLE Demo
Add this rules at tne end of your styles:
.fader-us:hover .fader-us-content {
display:block;
}
.fader-us:hover .us { opacity: 0; }

Related

Why doesn't it work when I hover on the image?

I'm sure this is incredibly stupid once I get a hint, but I can't see why the hover doesn't work. I added the jQuery just to check whether or not it works with a click.
$(document).on("click", ".figure", function() {
$(".popover").css("opacity", "1");
})
.container {
position: relative;
}
.popover {
background-color: blue;
position: absolute;
top: 0;
left: 200px;
opacity: 0;
transition: opacity 0.5s ease-in-out 0s;
}
.figure:hover .popover {
opacity: 1;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div class='container'>
<div class='figure'>
<img src='https://placehold.it/100' />
</div>
<div class='popover'>
<p>
Bla bla
</p>
</div>
</div>
Because your .popover div is not a child of .figure div.
Used + selector for this
$(document).on("click", ".figure", function() {
$(".popover").css("opacity", "1");
})
.container {
position: relative;
}
.popover {
background-color: blue;
position: absolute;
top: 0;
left: 200px;
opacity: 0;
transition: opacity 0.5s ease-in-out 0s;
}
.figure:hover + .popover {
opacity: 1;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div class='container'>
<div class='figure'>
<img src='https://placehold.it/100' />
</div>
<div class='popover'>
<p>
Bla bla
</p>
</div>
</div>
Change :
.figure:hover .popover {
opacity: 1;
}
To :
.figure:hover + .popover {
opacity: 1;
}
Try changing classes into id´s and than make hover.
JSFiddle link
#figure:hover + #popover {
opacity:1;
}

Bootstrap - I need to zoom image on the mouse hover, but keep its original size

I am trying to create a bootstrap grid with images with some padding, which are zoomed in on hover. The problem is that even after I set overflow to "hidden", they keep blocking the padding line I set - padding is set in the same element and for some reason they override it. For example, when I hover over the left image, it grows a bit and blocks the vertical white line in the middle. How can I force the css to respect the padding?
My html
<div class="row" style="height:100%">
<div class="col-md-6 img-hover" style="padding-right:3px;height:100%;overflow:hidden;">
<img class="img-responsive" src="Images/image.jpg")" style="overflow: hidden" />
</div>
<div class="col-md-6" style="overflow:hidden;height:100%; padding-right: 3px;">
<div class="row">
<img class="img-responsive" src="/Images/image2.jpg")" />
</div>
<div class="row" style="padding-top:3px;height:100%">
<div class="col-md-6" style="padding-left: 0px; padding-right: 3px">
<img class="img-responsive" src="/Images/image3.jpg")" />
</div>
<div class="col-md-6" style="padding-left: 0px; padding-right: 3px">
<img class="img-responsive" src="/Images/image3.jpg")" />
</div>
</div>
</div>
</div>
My css:
.img-hover img {
-webkit-transition: all .3s ease; /* Safari and Chrome */
-moz-transition: all .3s ease; /* Firefox */
-o-transition: all .3s ease; /* IE 9 */
-ms-transition: all .3s ease; /* Opera */
transition: all .3s ease;
overflow:hidden;
}
.img-hover img:hover {
-webkit-backface-visibility: hidden;
backface-visibility: hidden;
-webkit-transform:translateZ(0) scale(1.20); /* Safari and Chrome */
-moz-transform:scale(1.10); /* Firefox */
-ms-transform:scale(1.10); /* IE 9 */
-o-transform:translatZ(0) scale(1.10); /* Opera */
transform:translatZ(0) scale(1.10);
}
And this is the image I have. What changes should I do so the zoomed image stops blocking the padding line? Thanks a lot.
You can use overflow: hidden property on <div> block that is containing the <img>. And on :hover use transform: scale(x) property.
Have a look at the snippet below:
.grid-box {
display: flex;
flex-direction: column;
}
.first-row {
display: flex;
}
.grid {
border: 1px solid #fff;
overflow: hidden;
transition: all .3s linear;
}
.one, .two {
width: 100px;
height: 100px;
}
.three {
width: 202px;
height: 100px;
}
.grid:hover img {
transform: scale(2);
transition: all .2s linear;
}
<div class="grid-box">
<div class="first-row">
<div class="grid one">
<img src="http://placehold.it/100x100" alt="" />
</div>
<div class="grid two">
<img src="http://placehold.it/100x100" alt="" />
</div>
</div>
<div class="grid three">
<img src="http://placehold.it/202x100" alt="" />
</div>
</div>
Hope this helps!

CSS - stopping animation with :hover (no JS)

Is there any way of stopping animation with :hover and make it run again once hovered off?
This part is solved:
I thought of doing it with animation-state-paused, but as the animation runs on multiple elements with precised animation-delay, such solution desynchronizes elements.
What I would like to achieve 'at least' is to stop all of the animation once hovered.
Still looking for solution for this part:
And the Great Achievement would be (additionaly) to change z-index so the hovered picture goes in front of all the other ones... and come backs to its z-index from animation once hovered off + animation continues the cycle.
Important thing - NO JAVASCRIPT (I'd really like to use it, but I cannot because of some CMS settings).
Code without hover: CODEPEN and SOSnippet:
.cube2>div{
position:absolute;
left:50%;
transform: translateX(-50%);
width:450px;
}
.playground2 {
overflow: hidden;
}
.frame {
position: absolute;
top:-12px;
left:-1px;
z-index: 1;}
.one, .two, .three, .four, .five, .six, .seven, .eight{
animation: comedown 32s infinite ease-in-out
}
.eight {
animation-delay: 0s
}
.seven {
animation-delay: 4s
}
.six {
animation-delay: 8s
}
.five {
animation-delay: 12s
}
.four {
animation-delay: 16s
}
.three {
animation-delay: 20s
}
.two {
animation-delay: 24s
}
.one {
animation-delay: 28s;
}
.container {
background: darkkhaki;
height: 400px;
position: relative;
}
.cube2 {
top: 100px;
height: 300px;
position: relative;
left: 50%;
transform: translateX(-50%);
}
#-webkit-keyframes comedown {
0% {
top: 0%;
z-index: 1;
}
12.5% {
top: 120%;
z-index: 2;
left:50%;
transform:translateX(-50%);
}
13%{z-index:-15}
25%{
top:-50px;
transform: translateX(-32%)
}
35%{z-index:-10}
37.5%{
top:-42px;
transform: translateX(-35%);
}
50%{
top:-36px;
transform: translateX(-38%);
z-index:-6;
}
62.5%{
top:-28px;
transform: translateX(-41%);
z-index:-5;
}
75%{
top:-20px;
transform: translateX(-44%);
z-index:-4;
}
87.5%{
top:-12px;
transform: translateX(-47%);
z-index:-3;
}
100%{
top:0px;
left:50%;
transform:translateX(-50%);
z-index:-2;
}
}
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
<div class="playground2 container">
<div class="cube2">
<div class="one">
<img class="face" src="https://s17.postimg.org/71iegzebj/img_little.png">
<img class="frame" src="https://s16.postimg.org/5e6yfj8d1/frame.png">
</div>
<div class="two">
<img class="face" src="https://s17.postimg.org/duncqzuin/img_little3.png">
<img class="frame" src="https://s16.postimg.org/5e6yfj8d1/frame.png">
</div>
<div class="three">
<img class="face" src="https://s17.postimg.org/o3b8j2t6n/img_little2.png">
<img class="frame" src="https://s16.postimg.org/5e6yfj8d1/frame.png">
</div>
<div class="four">
<img class="face" src="https://s17.postimg.org/v97kz9rnj/img_little4.png">
<img class="frame" src="https://s16.postimg.org/5e6yfj8d1/frame.png">
</div>
<div class="five">
<img class="face" src="https://s16.postimg.org/4reke4owl/image.png">
<img class="frame" src="https://s16.postimg.org/5e6yfj8d1/frame.png">
</div>
<div class="six">
<img class="face" src="https://s16.postimg.org/3qebp07x1/image.png">
<img class="frame" src="https://s16.postimg.org/5e6yfj8d1/frame.png">
</div>
<div class="seven">
<img class="face" src="https://s16.postimg.org/fgs96e0ph/image.png">
<img class="frame" src="https://s16.postimg.org/5e6yfj8d1/frame.png">
</div>
<div class="eight">
<img class="face" src="https://s16.postimg.org/xxmnx7gnp/image.png">
<img class="frame" src="https://s16.postimg.org/5e6yfj8d1/frame.png">
</div>
</div>
</div>
The trick is to catch :hover on .cube2.
This will pause the animation:
.cube2:hover > div{
-webkit-animation-play-state: paused; /* Safari 4.0 - 8.0 */
animation-play-state: paused;
}
To bring image box to front using z-index, use this:
.cube2 > div:hover{
z-index: 99 !important;
}
.cube2:hover > div.one, .cube2:hover >.two, .cube2:hover >.three, .cube2:hover >.four, .cube2:hover >.five,.cube2:hover > .six, .cube2:hover >.seven, .cube2:hover >.eight{
animation-play-state: paused;
}
This way all animation is stopped since you call hover on .cube2
See:
https://jsfiddle.net/duuhr712/

addThis Sharing Buttons for Wordpress, how to animate?

I'm looking for a plugin/code that can give some nice mouse hover animation over addThis share buttons, but still want to enjoy the 1-click tweet,like,etc. feature of addThis default buttons.
The one i have now is default, looks like,
What i want is something similar to the one used in arduino.cc blog, the default 1-click buttons are hidden by default and get visible only on mouse hover.
eg:-
How can i achieve this?
You can do this placing custom Images with actual sharing buttons together.
Keep all the sharing button width 0 by default and make them visible on hover by increasing width.
Also add CSS transition to expend the buttons smoothly.
Consider this example.
.sharing-buttons {
float: left;
margin: 5px;
}
.share-button {
float: right;
margin-left: 5px;
overflow: hidden;
transition: all 0.6s ease 0s;
white-space: nowrap;
width: 0;
}
.sharing-buttons:hover .share-button {
width: 100px;
}
<div id="wrapper">
<div class="sharing-buttons fb">
Custom Image
<div class="share-button">Button iframe</div>
</div>
<div class="sharing-buttons tw">
Custom Image
<div class="share-button">Button iframe</div>
</div>
</div>
Edit: Final addThis code & CSS
.addthis_toolbox a.at300b, .addthis_toolbox a.at300m {
padding: 5px;
width: auto;
}
.social-container {
float: left;
margin: 5px;
width:auto;
}
.social-content {
float: right;
margin-left: 5px;
overflow: hidden;
-moz-transition: max-width .3s ease-out;
-webkit-transition: max-width .3s ease-out;
-o-transition: max-width .3s ease-out;
transition: max-width .3s ease-out;
white-space: nowrap;
max-width: 0;
}
.social-container:hover .social-content {
-moz-transition: max-width .2s ease-in;
-webkit-transition: max-width .2s ease-in;
-o-transition: max-width .2s ease-in;
transition: max-width .2s ease-in;
max-width: 95px;
}
<div class="addthis_toolbox addthis_default_style ">
<!-- FACEBOOK -->
<div class="social-container">
<img src="<?php bloginfo('template_directory'); ?>/images/facebook.png" alt="" />
<div class="social-content">
<a class="addthis_button_facebook_like at300b" fb:like:layout="button_count"></a>
</div>
</div>
<!-- G+ -->
<div class="social-container">
<img src="<?php bloginfo('template_directory'); ?>/images/gplus.png" alt="" />
<div class="social-content">
<a class="addthis_button_google_plusone" g:plusone:size="large"></a>
</div>
</div>
<!-- TWITTER -->
<div class="social-container">
<img src="<?php bloginfo('template_directory'); ?>/images/twitter.png" alt="" />
<div class="social-content">
<a class="addthis_button_tweet at300b"></a>
</div>
</div>
</div>

An empty space inside a div that is not margin or padding

There is a div, and an image inside that div, all margin set to 0 - however it keep showing a gab INSIDE the div, not even out side, it's not padding or margins and I can't seem to figure out what it is.
I have tried to change the Div's to sections, give them negative margins, make the height 100% but nothing works!
Here is the link to the site: http://www.webdesignstudents.co.uk/students/loai_shehadeh/1/portfolio.html
You can see the full code by View the Page Source, but here is the HTML I am using is this:
<div class="wrapperB">
<div class="content">
<div id="portfolio-sectionB" class="all">
<div id="grid1"><!--Gird 1-->
<div class="galleryItemB visualIdentity">
<img alt="Brighton and Hove In Bloom Logo" src="portfolio/images/brighton-in-bloom-logo-mockup-1.jpg">
</div>
<div class="galleryItemB visualIdentity">
<img alt="" src="portfolio/images/hovecollege-course-magazine-mockup2.jpg">
<p>Click To View Project</p>
</div>
<div class="galleryItemB visualIdentity">
<img alt="" src="portfolio/images/brighton-pet-show-poster-mockup3.jpg">
<p>Click To View Project</p>
</div>
</div><div id="grid2"><!--Gird 2-->
<div class="galleryItemB visualIdentity">
<img alt="" src="portfolio/images/ambition-world-bussiness-card-mockup.jpg">
<p>Click To View Project</p>
</div>
</div><div id="grid3"><!--Gird 3-->
<div class="galleryItemB visualIdentity">
<img alt="" src="portfolio/images/brighton-pet-show-logo-mockup.jpg">
<p>Click To View Project</p>
</div>
<div class="galleryItemB webDesign visualIdentity">
<img alt="" src="portfolio/images/animal-recuse-group-logo-mockup.jpg">
<p>Click To View Project</p>
</div>
</div>
</div>
</div>
</div>
The CSS
#portfolio-sectionA {
margin: 10px 20px;
}
#portfolio-sectionA a {
color: #CED9E7;
padding: 7px 10px;
margin-left: -1px;
border-radius: 3px;
-moz-border-radius: 3px;
-webkit-border-radius: 3px;
}
#portfolio-sectionA a:hover {
color: #9BAFCE;
}
#portfolio-sectionA a:active, #portfolio-sectionA a.portfolio-sectionAClicked {
color: #4E6C98;
background-color: #3C5476;
cursor: default;
}
/*---Portoflio Page Section B---*/
.galleryItemB {
background-color: green;
position: relative;
}
#portfolio-sectionB .galleryItemB a {
position: absolute; left: 0; top: 0; right: 0; bottom: 0;
background: url(../elements/magnifying-glass.png) center center no-repeat rgba(78,108,152,.85);
cursor: pointer;
opacity: 0;
-moz-opacity: 0;
-khtml-opacity: 0;
filter:alpha(opacity=0);
-webkit-transition: opacity 0.2s linear;
-moz-transition: opacity 0.2s linear;
-ms-transition: opacity 0.2s linear;
-o-transition: opacity 0.2s linear;
transition: opacity 0.2s linear;
}
#portfolio-sectionB .galleryItemB:hover a {
opacity: 1;
-moz-opacity: 1;
-khtml-opacity: 1;
filter:alpha(opacity=100);
}
#portfolio-sectionB .galleryItemB a p{
color: #FFFFFF;
position: absolute; bottom: 15px; right: 20px;
cursor: pointer;
}
Change the styling on the images within the div's to display:block.
Ex:
itemWrapper > img {
display:block;
}
img is inline-lbock element and a is inline element. Hence simple text whitespaces appear between them.
In your CSS file you add paddings, margins and borders and stuff.
Then you have an use all classess in your html file.
This might be one of the divs that causes the problem.
You added the padding and other offsets by including all classes, it includes all css classes.
In your css class you have an #portfolio-sectionB part with offsets.
If you really don't know what it is you could always comment out all the CSS properties in the CSS file and enable them one by one while checking if the bug returns.
And fix the spelling mistakes in your html comments: change Gird into Grid.
I'm not sure if this is what you mean but it seems that the links itself have a padding. This results in a white border around the images.

Resources