If mouse on text as hover flickering text.
div {
position: absolute;
font-size: 40px;
color: black
}
.new {
opacity: 0;
visibility:hidden;
}
.old:hover {
opacity: 0;
visibility:hidden;
}
.new:hover {
opacity: 1;
visibility: visible;
}
<div class="old">Old</div>
<div class="new">New</div>
How i can show text New if mouse hover (without wrapper please)?
Code on JSFiddle
You can simply use content along with :after to replace text
div {
position: block;
font-size: 40px;
color: black
}
.old:after{
content:'old';
}
.old:hover:after{
content:'new';
}
<div class="old"></div>
Edited
I think you have been asking that old must disappear on hover and new must stay forever even after hover effects.
This can be done by transition effects. This time I go for Allan Jebaraj's answer using z-index and altering the opacity transition effects.
div {
position: absolute;
font-size: 40px;
color: black
}
.new {
opacity: 0;
transition: opacity 9999s;
}
.old {
z-index: 1;
transition: opacity 9999s;
}
.old:hover {
opacity: 0;
transition: opacity 0s;
}
.old:hover+.new {
opacity: 1;
transition: opacity 0s;
}
<div class="old">old</div>
<div class="new">new</div>
I think this is what you are asking. Set the transition time as large as possible to make sure they don't revert back to normal as user stays.
You can try this
div {
font-size: 40px;
color: black
}
.new {
display: none;
}
.old:hover + .new {
display: block;
}
You have to set the z-index of the class .old and use the adjacent sibling selector to hide the old class and display the .new class.
Refer the JSFiddle below.
JSFiddle link
div {
position: absolute;
font-size: 40px;
color: black
}
.new {
opacity: 0;
}
.old {
z-index: 1;
}
.old:hover {
opacity: 0;
}
.old:hover+.new {
opacity: 1;
}
<div class="old">Old</div>
<div class="new">New</div>
Related
I show a tooltip when an input gains focus. This tooltip is a span: hidden, but shown (via CSS) when input has focus.
input + .k-comments {
display: none;
max-width: 25em;
color: #FFF;
background: #283135;
padding: 0.3rem;
margin-top: 0.3rem;
animation: appearance 2s forwards;
}
input:focus + .k-comments {
display: block;
}
<input id="myid" type="text"/>
<span class="k-comments">foo a link</span>
If I click on the tooltip (or everywhere else), it disappears: ok.
The problem: my tooltip contains text and a link -> I can't click on the link because the tooltip disappears first.
Probably not the best solution but at least it makes the link clickable:
input:focus + .k-comments,
.k-comments:active {
display: block;
}
input + .k-comments {
visibility: hidden;
opacity: 0;
max-width: 25em;
color: #FFF;
background: #283135;
padding: 0.3rem;
margin-top: 0.3rem;
transition: all 2s linear;
}
input:focus + .k-comments {
visibility: visible;
opacity: 1;
transition: none;
}
My solution :add a hidden transition to the comment.
Hey I made a small hover effect but there is a bug in it which I seem not to be able to remove by myself, so hopefully someone can help me :(
[here]https://jsfiddle.net/5a4jh4pc/
this is the hover effect.
The hover width is not arranged to 100% of the image size
The hover effect even starts if you are close to the image on the right side. (it should only do the effect when the mouse is ON the image, not next to it.)
I hope someone can help me here to fix this. Thanks in advance!
You have your container set to a certain size, which the hover effect is triggered over, and the image is set to 70% of this.
This means that you have 30% of the container to the right still activating the hover, but containing no image.
Change the figure width to suit your needs
figure {
display: inline-block;
position: relative;
float: left;
overflow: hidden;
width: 300px;
}
figcaption {
position: absolute;
background: black;
background: rgba(0,0,0,0.75);
color: white;
opacity: 0;
-webkit-transition: all 0.6s ease;
-moz-transition: all 0.6s ease;
-o-transition: all 0.6s ease;
font-size: 12px;
line-height: 15px;
}
figure:hover figcaption {
opacity: 1;
}
figure:hover:before {
opacity: 0;
}
.cap-bot img {
float:left;
width:100%;
}
.cap-bot:before { width:0%;padding: 10px 10px;bottom: 10px; }
.cap-bot figcaption { width:100%;padding: 10px 10px;left: 0; bottom: -30%;}
.cap-bot:hover figcaption {width:100%;padding: 10px 10px;bottom: 0; }
Forked https://jsfiddle.net/hjhbrosh/
Remove left and right padding in your figcaption and use word-wrap: break-word; to wrap the text to the next line when it overflows and use a div inside your figcaption to retain that padding.
.cap-bot figcaption {
width:70%;
padding: 10px 0px;
left: 0;
bottom: -30%;
}
.cap-bot:hover figcaption {
width:70%;
padding: 10px 0px;
bottom: 0;
}
Check this fiddle
I am trying to show the caption on my products when you hover. I manage to get it, but the black won't show black, like I have some kind of white background on top of my effect. You can see it there
Here's the CSS I added
.product:hover .reveal img {
opacity: 1;
z-index: 1;
}
.reveal .hidden {
position: absolute;
z-index: -1;
top: 0;
width: 100%;
height: 100%;
margin-top: -20px;
}
.reveal:hover .hidden {
z-index: 1;
opacity: 1;
}
.reveal .caption {
position: absolute;
top: 0;
display: table;
width: 100%;
height: 100%;
background: rgba(255, 255, 255, 1);
color: rgba(0, 0, 0, 1) !important;
font: 12px/1.4em sans-serif;
text-transform: uppercase;
letter-spacing: 0.3em;
text-align: center;
}
.reveal .hidden .caption .centered {
display: table-cell;
vertical-align: middle;
}
Do you think it is as basic as a z-index problem, or is it more in the way I constructed it ?
That's because you have an hover effect the animate the .image-wrapper to opacity:0.5. If you set .product-grid .image-wrapper {opacity:1 !important) (just for the test you can see that the black is black.
So what can you do?
Do the fadeOut effect on the .reveal > img. In this way the .product-grid .image-wrapper will stay opacity:1.
try this
.reveal:hover .hidden {
z-index: 0;
opacity: 0.8;
}
One of the problems was the .caption was the same size as the image it was positioned over, and had a 1.0 alpha background- meaning the caption box covered the image entirely once the z-index let it pop in front.
The other problem is the js/jQ doing an animation on rollover. Just nix the code adding the hover handler to it. If you want a fade-in/out still, put the base z-index on your caption to make it naturally be in front, and animate its opacity up to 100% on :hover. This is opposed to animating the opacity of the whole tile from 100% to 50% and switching the stacking order.
.image-wrapper:hover {
opacity: 1 !important;
}
that will fix it. When you hover it goes to 0.5, this will stop it.
I'm trying to write code that shows text over image and I'm trying to achieve an hover effect. I post the code at http://codepen.io/kikibres/pen/LVxmBG so that you can take a look to see how it works. As you can see, when you hover over the image, it darkened, but the text background isn't affected. Likewise, when you hover over the text background, the image effect isn't activated. I wanted to connect them together but how? It looks like that I might have to edit the html, I think?
Html code:
<div class="fourcolumns">
<div class="productpic">
<a href="#">
<img src="http://i.imgur.com/SZen19w.png" alt="Scuba">
<h2 class="captioncolumn"><span>SCUBA</span></h2>
</a>
</div>
</div>
CSS code:
.fourcolumns { width: 100%; position: relative; margin: 40px 0;}
.productpic { width: 25%; float: left; display: inline-block; position: relative; margin: 0; padding: 0; background-color: #000000;}
.productpic a { }
.productpic img { width: 100%; opacity: 1;}
.productpic img:hover { opacity: 0.5;}
.productpic .captioncolumn { width: 80%; /*height: 50px;*/ background-color: #ffffff; position: absolute; top: 20px; left: 0; opacity: 1; padding: 5px 0 5px 20px;}
.productpic .captioncolumn span { font-family: 'Oswald', sans-serif; font-weight: 300; font-size: 36px; position: relative; color: #2a286a; opacity: 1; }
.productpic .captioncolumn:hover { opacity: 0.5;}
Use this will help
.productpic img:hover .productpic .captioncolumn,.productpic img { opacity: 0.5;}
It all boils down to a link which ties everything together so that no matter which area of the box are hovered over, it's all activated, instead of one area, when hovered over, showing a hover effect and other areas not showing a hover effect. However, I don't want the text box to be affected in the hover effect. Therefore I looked around for answer for making only the child element activated inside the a parent link. Here's the answer:
.productpic a:hover img { opacity:0.5; }
You can also see the final result at http://codepen.io/kikibres/pen/MwJzqO?editors=110
Okay.As per your comment the suggestion is to use the way-
.productpic img:hover + h2{ background:transparent;}
.productpic img:hover {
opacity: 0.5;
}
link
I'm working on a CSS hide/show effect. It works fine on Firefox. You click on it, the Hello World text appears. Then you click again, and it disappears.
But on Chrome/Safari, you have to click and hold the button to make it appear.
How can I make it work properly on Chrome/Safari like it does on Firefox?
Here is jsfiddle.
HTML:
<div class="formatting_show" id="formatting_show"></div>
<span id="formatting_content"> Hello World </span>
CSS:
#formatting_show {
cursor: pointer;
cursor: hand;
float: right;
font-size: 30px;
height: 15px;
text-align: right;
width: 74px;
color: #000;
}
#formatting_content {
display: block;
-webkit-transition: opacity 1s ease-out;
transition: opacity 1s ease-out;
opacity: 0;
height: 0;
font-size: 0;
overflow: hidden;
}
#formatting_show:before {
content: "Formatting «"
}
#formatting_show:active.formatting_show:before {
content: "Formatting »"
}
#formatting_show:active ~ span#formatting_content {
font-size: 30px;
height: 70px;
opacity: 1;
}
#formatting_content {
float: left;
}
I agree with #Huangism who wrote in a comment, that this isn't possible with the :active pseudo class. However, you could use a HTML checkbox, a label for that checkbox and the general sibling selector in CSS (see also).
This is all the HTML code:
<input id="formatting_show" type="checkbox" />
<label for="formatting_show">Formatting</label>
<div class="formatting_content">Hello World</div>
And the complete CSS code:
#formatting_show {
display: none;
}
.formatting_content {
display: none;
}
#formatting_show:checked ~ .formatting_content {
display: block;
}
You can take a look at a running example.