Having html code with several hash links (e.g.href="#login") and css using pseudo selector :target for animation, such as
#login:target ~ #wrapper #console {
-webkit-animation-timing-function: ease-out;
-moz-animation-timing-function: ease-out;
-o-animation-timing-function: ease-out;
-ms-animation-timing-function: ease-out;
animation-timing-function: ease-out;
-webkit-animation-name: scaleOut;
-moz-animation-name: scaleOut;
-o-animation-name: scaleOut;
-ms-animation-name: scaleOut;
animation-name: scaleOut;
}
I would like to add a feature of conditional behavior, based on "source" of the trigger event.
Let's say the html code with
<a class="hidden" id="login"></a>
<div id="wrapper">
<div id="console" class="animate">
...
has somewhere also two links
<a id="link_1" href="#login">
and
<a id="link_2" href="#login">
both pointing to #login. Is it possible to modify css to have different behavior for each of links? In my case, is it possible by pure html and css to do different kinds of animation for both links?
No. :target is the only CSS selector of its type; for any other “behaviour”, you need JavaScript or something server-side.
The closest you can get is #login1 and #login2.
This isn't possible, as you ask it, since CSS has no capacity to conditionally-assess the source of the activity, and is only able to 'react' to the end-result, without the ability to reference the source of the action that 'caused' the :target selector to match.
That said, if you're able to change your HTML, and one of the links, you could approximate it:
<a id="link_1" href="#hidden">Link One</a>
<a id="link_2" href="#login">Link Two</a>
<div id="hidden"></div>
<a class="hidden" id="login"></a>
<div id="wrapper">
<div id="console" class="animate">
</div>
You can target differently:
#hidden:target + #login {
/* style, or trigger animation */
}
#login:target {
/* style, or trigger different animation */
}
The problem, of course, is that this clearly doesn't directly cause the :target selector to match the relevant element in both cases, so the answer must remain, basically: 'no,' this is a case in which JavaScript is probably the only real solution to meet your needs.
Related
I'm just building a locally hosted website. I will have a number of pages, 1,2,3 etc. And I wanted to create a kind of a slideshow effect by cycling slowly through each page. Using http-equiv="refresh" on each page I can link from page 1 to 2, page 2 to 3, page 3 to 1 etc. Going full screen on the browser creates a lovely slideshow effect of the website.
I'm a low enough level, but I would like to be transition from one page to the other smoothly, either fade in fade out or whatever. Right now it's quite jumpy.
Anyway, is this something I can do using the current meta tag or should I use an alternative method?
I would prefer C# over Java if required.
<head>
<META HTTP-EQUIV="refresh" CONTENT="8;URL=/page1">
</head>enter code here
Should be possible like that's:
<html>
<head>
<style>
.container {
opacity: 0;
transition: opacity 1s;
}
.container-loaded {
opacity: 1;
}
</style>
</head>
<body>
<div class="container">
<!-- All the content you want to fade-in here. -->
</div>
<script>
$(document).ready(function() {
$('.container').addClass('container-loaded');
});
</script>
</body>
</html>
Thanks to #d4rk_Devs answer for giving me inspiration. I went on a rambling foray through google and stackoverflow and came up with the following code which worked perfectly.
<iframe src="..."
onload="this.style.opacity = '1';"
style=" opacity: 0;
transition-duration: 2s;
transition-property: opacity;
transition-timing-function: ease-in-out;"
></iframe>
can be seen here Original Code
I'm trying to fade in a textbox via CSS keyframes:
.otherAnim{
animation-delay:11s;
animation-duration:2s;
animation-iteration-count:1;
animation-fill-mode: forwards;
}
#keyframes Appear{
from {opacity:0;}
to {opacity:1;}
}
<div class="col" style="width:30%;height:100%">
<h2>some text</h2>
<h2 class="otherAnim" style="animation-name:Appear;opacity:0;">some text: </h2>
<input type="text" id=myInput class="otherAnim inputSoFar" style="animation-name:Appear;float:left;height:45px;opacity:0;">
</div>
This works on JSFiddle, but not in my local view of the page (Chrome 57). The weird thing for me is that if I inspect the element, the otherAnim class has dissapeared. This doesn't happen in JSFiddle. I'm using w3.css, but it still works if I load it as a external resource in JSFiddle.
What am I possibly missing ?
Don't put the animation-name property in inline style. You have to put it in the style tag or a linked css file.
I'm suffering to active color on my template, I have used this template http://codepen.io/suez/pen/XJGOyL
How can I active menu, like when I clicked another menu not active. how to do this?
This is my code:
//HTML
<div class="demo__content">
<h2 class="demo__heading">What do you need help with?</h2>
<div class="demo__elems">
<div class="demo__elem demo__elem-1">With advertising online</div>
<div class="demo__elem demo__elem-2">With a website</div>
<div class="demo__elem demo__elem-3">I need help with both</div>
<span class="demo__hover demo__hover-1"></span>
<span class="demo__hover demo__hover-2"></span>
<span class="demo__hover demo__hover-3"></span>
<div class="demo__highlighter">
<div class="demo__elems">
<div class="demo__elem">With advertising online</div>
<div class="demo__elem">With a website</div>
<div class="demo__elem">I need help with both</div>
</div>
</div>
</div>
//CSS
.demo__hover-2 {
top: 7rem;
}
.demo__hover-2:hover ~ .demo__highlighter {
-webkit-transform: translateY(7rem);
transform: translateY(7rem);
}
.demo__hover-2:hover ~ .demo__highlighter .demo__elems {
-webkit-transform: translateY(-7rem);
transform: translateY(-7rem);
}
.demo__hover-3 {
top: 14rem;
}
.demo__hover-3:hover ~ .demo__highlighter {
-webkit-transform: translateY(14rem);
transform: translateY(14rem);
}
.demo__hover-3:hover ~ .demo__highlighter .demo__elems {
-webkit-transform: translateY(-14rem);
transform: translateY(-14rem);
}
.demo__elem a:active, a:hover, a:focus {
text-decoration: none;
outline: none;
}
If you are able to use jQuery in you code you can do it by adding "active" class to selected element of your menu.
For instance
$(".demo__elem").click(function() {
$(".demo__elem").removeClass("active"); // remove active from all
$(this).addClass("active"); // add active to this
});
and you "active" css should be styled as well.
If you're wanting to click a link, go to that page, and have that link retain the active state once you're on that page, you'll need to do one of three things.
Using HTML and CSS only, every page can be built completely and individually. This is called a static website. The menu will live on each page, and the link for the page you're on will need a unique ID (usually class="active") in order to set it apart as the active link. Using CSS, you can style to appear how you want.
You can use javascript to dynamically detect the page you're on, usually by reading your URL, and apply the active state to the appropriate link.
You can use a server side codding language such as PHP, ASP, RUBY, etc., and set your menus to dynamically detect which page you're on based on internal/server side code and apply the active state to the menu. This is a very clean, and once you get the hang of the language you choose, it's a very easy and effective method. This is the most popular choice by developers and is called a dynamic website.
In each case, you'll still use CSS the exact same way to style the active link.
I am trying to use the tada animation from font awesome with a custom font I generated from fontastic. I have added the font-awesome-animation.min.css to the header of my WordPress theme file. I have also added this html code to my site (see the membership icon).
<a class="faa-parent animated-hover" href="#">
<div class="service-icon-container">
<div class="fa icon icon-membership faa-tada"></div>
</div>
<h3>Membership</h3>
<p>Membership info text</p>
</a>
Any suggestions on making it work?
You forgot to change the reference of hover class in css.
for your membership icon try adding following code:
a.faa-parent:hover .service-icon-container > .fa.icon {
-webkit-animation: tada 2s linear infinite;
animation: tada 2s linear infinite;}
for all other icons, add anchor tag as you added for membership.
After changing styles to some inner divs hover transition stopped working. To see if that was the cause, i removed new styling, but the problem stayed. Can't understand why.
Live link is here
.com/
It's these blocks on the left of the slider
html code (though it's the same with the one that was working just fine before)
<div class="slidersidehover slidersideheight" id="sliderside1">
<div id="sliderside1title"></div>
<div id="sliderside1content"></div>
</div>
<a href="" target="_blank">
<div class="slidersidehover slidersideheight" id="sliderside2">
<p id="sliderside2txt"></p>
<div id="sliderside2bg"></div>
</div></a>
<a href="" target="_blank">
<div class="slidersidehover slidersideheight" id="sliderside3">
<p id="sliderside3txt"></p>
<div id="sliderside3bg"></div>
</div></a>
and css
.slidersidehover {
background-color:black !important;
transition:0.3s;
-ms-transition:0.3s;
-o-transition:0.3s;
-moz-transition:0.3s;
-webkit-transition:0.3s;
}
.slidersidehover:hover {
opacity:0.5;
}
try to remove html comment <!--slider--> in your style.css
and use css comment: /* slider */
As far as I understand transitions only happen if you declare the property on both the active state and rest state.
.slidersidehover {
opacity:1;
background-color:black !important;
transition:0.3s;
-ms-transition:0.3s;
-o-transition:0.3s;
-moz-transition:0.3s;
-webkit-transition:0.3s;
}
.slidersidehover:hover {
opacity:0.5;
transition:0.3s;
-ms-transition:0.3s;
-o-transition:0.3s;
-moz-transition:0.3s;
-webkit-transition:0.3s;
}
I am not sure exactly what effect you are going for but for explanation purposes I set the opacity to 1 on the rest state and then opacity to 0.5 on your hover. That should fix the issue.