Hover effect transition not working - html

I have been trying to create a hover image effect in my website. I attached the script in the below link.
I can't able to set a hover image transition fade effect and 2s time delay.
Please help me.
<div class="imagecontainer">
<img class="myhoverimg" src="http://www.gettyimages.ca/gi-resources/images/Homepage/Category-Creative/UK/UK_Creative_462809583.jpg" alt="">
<div class="myhoveroverlay"></div></div>
<style>
.imagecontainer {
position:relative;
width:361px;
height:181px; }
.myhoverimg{
position:absolute;
top:0;
left:0;
width:100%;
height:100%;
}
.myhoveroverlay{
position:absolute;
top:0;
left:0;
width:100%;
height:100%;
z-index:100;
}
.myhoveroverlay:hover{
background:url(http://css3.bradshawenterprises.com/images/Windows%20Logo.jpg);
}
</style>
https://jsfiddle.net/nhu2wmdg/

You can use opacity attr to fade image...
.myhoveroverlay{
position:absolute;
top:0;
left:0;
width:100%;
height:100%;
z-index:100;
opacity : 1;
}
.myhoveroverlay:hover{
background:url(http://css3.bradshawenterprises.com/images /Windows%20Logo.jpg);
opacity : 0.9;
}

Thanks for the help #Leo. Exactly what i was looking for.
jsfiddle.net/nhu2wmdg/1

Related

Adding glow to border-style dotted

I have a question regarding on styling the border-style: dotted.
What I want to achieve is adding the glow on each of the circle/dot. Is it possible or achievable?
Since each time I try to add the glow effect, it will go directly towards whole edge of the div border.
I would like to add glow effect to those tiny little dots.
Hope anyone could enlighten me on this matter.
Thank you!
You can try a drop-shadow filter:
.box {
display:inline-block;
padding:30px 80px;
position:relative;
z-index:0;
}
.box::before {
content:"";
position:absolute;
z-index:-1;
inset:0;
border-radius:100px;
border:10px dotted red;
filter:drop-shadow(0 0 3px green);
}
<div class="box">
Some text
</div>
Even a blur filter can work to give a different output:
.box {
display:inline-block;
padding:30px 80px;
position:relative;
z-index:0;
}
.box::before {
content:"";
position:absolute;
z-index:-1;
inset:0;
border-radius:100px;
border:10px dotted red;
filter:blur(2px);
}
<div class="box">
Some text
</div>

z-index not working in the service item

When I hover the service item, it does not appear above the other items. I am trying to set the z-index but it's not working. What do I next?
Here is my demo link:
http://sarower.me/projects/
Add the z-index for the parent.
.creb.animated.fadeInUp:hover {
z-index: 10;
}
You could try:
.creb:hover {
z-index: 100;
}
That will set the z-index before the animation begins.
Well you have not added any code, but it's a z-index issue so you can see below example and update or make changes to your code, hope this help.
#b1{
width:32%;
height:200px;
background:#111;
position:relative;
float:left;
transition:1s ease;
z-index:-1;
}
#b1:hover{
transform:scale(1.1,1.1);
z-index:9;
}
#b2{
width:32%;
height:200px;
background:#ff1;
position:relative;
float:left;
transition:1s ease;
z-index:-1;
}
#b2:hover{
transform:scale(1.1,1.1);
z-index:9;
}
#b3{
width:32%;
height:200px;
background:#f11;
position:relative;
float:left;
transition:1s ease;
z-index:-1;
}
#b3:hover{
transform:scale(1.1,1.1);
z-index:9;
}
<div id="b1"></div>
<div id="b2"></div>
<div id="b3"></div>
Try this its working for me
.creb:hover {
z-index: 9999999999;
}

Fade out sides of div tag with image background CSS

I'm building a site, and I have an animating image in my header. This image is a coloured bar that animates from right to left on a loop to give the impression of it infinitely moving left.
What I would like to accomplish, is to have a fade in/out effect on the left and the right side of the image, without affecting the animation of it's background image.
This is my HTML code:
<div id="hbaranim"><div id="hbarchild"></div></div>
And my current CSS (with just the animating image):
#hbaranim {
width: 100%;
height: 5px;
overflow-x: hidden;
padding-bottom: 10px;
padding-top: 10px;
}
#hbaranim #hbarchild {
position: relative;
width: 8524px;
height: 5px;
background-image: url("img/colorbartile.png");
background-repeat: repeat-x;
-webkit-animation: hbaranim_roll linear 245s infinite;
}
#-webkit-keyframes hbaranim_roll {
from { right: 0px; }
to { right: 2131px; }
}
JSFiddle
Eddit: Currently using the HTML is using two div tags, but they don't have any content in them, so using just one would probably be better (not sure how to that to be honest...)
Eddit 2: Just to clarify, the animating image is positioned over a gradient background, so just putting another gradient over the image like some of you suggested won't work in this case. It really need's to be transparent at the sides.
Eddit 3: Some of you also suggested using a CSS gradient instead of an image, but the image I use on my actual site contains some other details that would be impossible to replicate in CSS. For this example I used an image that could indeed be replicated with a CSS gradient quite easily.
Eddit 4: Updated the fiddle to include the whole header
You could use absolutely positioned pseudo elements on the parent element with gradient backgrounds to achieve this. You can also achieve the same effect with a single div.
UPDATE: Following on from edit 3 in the original question, the rainbow gradient I've used below can be replaced with an image file, the exact same principles apply.
More information on pseudo elements
More information on gradients
EXAMPLE
*{box-sizing:border:box;}
body{margin:0;}
.header{
background:radial-gradient(ellipse at center,#242424 0%,#141414 100%);
box-shadow:0px 0px 10px 3px rgba(0,0,0,.75);
height:150px;
position:relative;
}
h1{
color:#fff;
font-family:arial;
font-size:48px;
padding:25px 0 0;
margin:0;
text-align:center;
}
h2{
color:#fff;
font-family:arial;
font-size:24px;
line-height:25px;
margin:0;
text-align:center;
}
#hbaranim{
-webkit-animation:hbaranim_roll linear 10s infinite;
animation:hbaranim_roll linear 10s infinite;
background:linear-gradient(90deg,#f00 0%,#ff0 16.667%,#0f0 33.333%,#0ff 50%,#00f 66.667%,#f0f 83.333%,#f00 100%) 0 0 repeat-x;
background-size:200%;
bottom:10px;
height:5px;
position:absolute;
width:100%;
}
#hbaranim::before,#hbaranim::after{
content:"";
display:block;
height:100%;
position:absolute;
top:0;
width:25%;
z-index:1;
}
#hbaranim::before{
background:linear-gradient(90deg,rgba(20,20,20,1),rgba(20,20,20,0));
left:0;
}
#hbaranim::after{
background:linear-gradient(90deg,rgba(20,20,20,0),rgba(20,20,20,1));
right:0;
}
#-webkit-keyframes hbaranim_roll{
0%{
background-position:0 0;
}
100%{
background-position:200% 0;
}
}
#keyframes hbaranim_roll{
0%{
background-position:0 0;
}
100%{
background-position:200% 0;
}
}
<div class="header">
<h1>Name of Site</h1>
<h2>www.site.nl</h2>
<div id="hbaranim"></div>
</div>
If you're feeling adventurous, you can do this without the nested div (Fiddle) or even without the parent div (Fiddle)
The following snippet was provided as an example while awaiting Ties' confirmation that removing the child div was an option and is included below as a matter of record.
#hbaranim{
overflow:hidden;
padding:10px 0;
position:relative;
width:100%;
}
#hbaranim #hbarchild{
background-color:#000;
height:20px;
position:relative;
width:8524px;
z-index:1;
}
#hbaranim::before,#hbaranim::after{
content:"";
display:block;
height:20px;
position:absolute;
top:10px;
width:20%;
z-index:2;
}
#hbaranim::before{
background:linear-gradient(90deg,rgba(255,255,255,1),rgba(255,255,255,0));
left:0;
}
#hbaranim::after{
background:linear-gradient(90deg,rgba(255,255,255,0),rgba(255,255,255,1));
right:0;
}
<div id="hbaranim">
<div id="hbarchild"></div>
</div>

Hover state and transition in Chrome - multiple animations on one element do not apply

When I apply transition in Chrome(24.0.1312.57) on hover it does not update background-color on mouse out. See this fiddle: http://jsfiddle.net/WKVJ9/
Here is the code:
.transition{
-webkit-transition: all 500ms ease-in-out;
}
.wrapper{
width:200px;
height:200px;
display:block;
background-color:cyan;
position:relative;
}
.hoverme{
border-radius:90px;
display: block;
width:50px;
height:50px;
top:50px;
right:-90px;
position:absolute;
-webkit-transform: rotate(-45deg);
}
.wrapper:hover .hoverme{
-webkit-transform: rotate(0deg);
right:0;
}
.hoverme:hover{
background-color:red;
}
and html:
<div class="wrapper">
<div class="hoverme transition">
Hover me
</div>
</div>
If you hover .wrapper and .hoverme and then quickly move mouse away from this box the .hoverme element will only animate rotation and position.
On the site I am working on it does not even refresh hover state so when the animation is finished and the background stays with :hover background-color... Which for some reason I cannot reproduce here
Is it possible to make the background animate?
This is happening because of position:absolute in .hoverme
try changing it to position:relative add margin-left:150px; (or required) to correct position of .hoverme ... like this:
.hoverme{
border-radius:90px;
display: block;
width:50px;
height:50px;
top:50px;
right:-90px;
position:relative;
margin-left:150px;
-webkit-transform: rotate(-45deg);
}
check it in action here: http://jsfiddle.net/WKVJ9/1/

Is it possible to shift the color of a div using css?

Update: The original phrasing of this question was vague so i've modified it to better express what i'm asking.
Lets say I have two divs
<div class='button'>A</div>
<div class='button green-button'>A</div>
with the following styles:
div.button {
/* define position, size, etc ...*/
color:#FBB
background-color:#F00
}
div.button.green-button{
color:#BFB
background-color:#0F0
}
In this example it was easy to shift the hue of the first button from red to green by simply changing shifting the values of color and background-color by 1 digit. If I wanted to make a blue button I could do the same shift again for a 3rd button.
However, in the case where I don't want to shift completely from one color to the next its a bit trickier.
Additionally I want to color shift everything in the div, not just the background-color and color properties. So if I were to place and image in the div the colors of the image would get shifted as well.
Is this possible in CSS? If not can you do it in Javascript?
Since everyone is posting wild guesses, I'll jump right into it.
You could achieve something using CSS filters (in your case hue-rotate)
Or the same using a CSS preprocessor like LESS.
Do you mean like this:
DEMO
HTML:
<a class="button">A</a>​
CSS:
.button{
font-family:sans-serif;
font-size: 80px;
display:block;
line-height:100px;
text-align:center;
color:rgba(255,255,255,0.5);
width:100px;
height:100px;
background-color:green;
}
.button:hover{
background-color:red;
}
​
Or are you looking for something that figures out the color offset on it's own?
If you are there is CSS3's filter: hue-rotate(angle);
DEMO
HTML:
<a class="button">A</a>​
CSS:
.button{
font-family:sans-serif;
font-size: 80px;
display:block;
line-height:100px;
text-align:center;
color:rgba(255,255,255,0.5);
width:100px;
height:100px;
background-color:green;
}
.button:hover{
-webkit-filter:hue-rotate(250deg);
-moz-filter:hue-rotate(250deg);
-ms-filter:hue-rotate(250deg);
filter:hue-rotate(250deg);
}
​
Yeah, you'll need multiple elements though.
HTML:
<div>
<span class="over-bg"></span>
<span>A</span>
</div>​
CSS:
div, span { height:100px; width:100px; vertical-align:middle;
text-align:center; }
div { background-color:#ff3300; position:relative; margin:20px; float:left; }
span { position:absolute; left:0; top:0; height:100%; width:100% }
span.over-bg { background-color:#22FF00; display:none; }
div:hover span.over-bg { display:block; }
http://jsfiddle.net/TeCvr/1/
Another approach using pseudo-elements:
HTML:
<div>
<span>A</span>
</div>​
CSS:
div, span { height:100px; width:100px; vertical-align:middle;
text-align:center; }
div { background-color:#ff3300; position:relative; margin:20px; float:left; }
span { position:absolute; left:0; top:0; height:100%; width:100% }
div:hover:before { display:block; content:""; position:absolute; left:0;
top:0; height:100%; width:100%; background-color:#22FF00; }
http://jsfiddle.net/TeCvr/2/
Well you could use CSS3 supported transition style rules like:
.button:hover {
background-color: #F0F0F0;
-webkit-transition: background-color 1ms linear;
-moz-transition: background-color 1ms linear;
-o-transition: background-color 1ms linear;
-ms-transition: background-color 1ms linear;
transition: background-color 1ms linear;
}
Is there any specific reason as to why you would like to achieve this..? I can't think of any application as such; unless you came across this while reverse engineering a design and couldn't find the CSS that caused this behaviour..?
Reference:
http://www.css3.info/preview/css3-transitions/
I don't know if i understand you. You can change the class of the div. For example .button to .buttongreen with diferent properties.
Without using color and background-color properties, you can still use:
background-image: linear-gradient(to bottom, #006e2e 0%,#006e2e 100%)
That's a gradient from a given color to the same color but the whole gradient is not a color in CSS.