How to transition two classes simultaneously using CSS - html

I am having trouble transitioning fade in simultaneously on two classes when I hover over either one of them.
.sv-logo {
opacity: 0.5;
transition: all .3s;
}
.nav{
opacity: 0.5;
transition: all .3s
}
.sv-logo:hover, .sv-logo:hover + .nav{
opacity: 1;
transition: all .3s;
}
.nav:hover, .nav:hover + .sv-logo{
opacity: 1;
transition: all .3s;
}
<div class="grid">
<div class="sv-logo">
<img id="logo1" src="images/logo.png" alt="logo">
</div>
<div class="nav">
<nav>
<ul>
<li>Portfolio</li>
<li>About</li>
<li>Contact</li>
</ul>
</nav>
</div>
</div>
The above CSS works when I hover on top of .sv-logo, both classes fade in. However, when I hover over .nav, only .nav fades in.

Your problem lies in the fact that the adjacent sibling selector only selects the following element. It can't select the previous element.
Consider encapsulating in another container, maybe header
header {
opacity: 0.5;
transition: all .3s;
}
header:hover{
opacity: 1;
transition: all .3s;
}
<div class="grid">
<header>
<div class="sv-logo">
<img id="logo1" src="images/logo.png" alt="logo">
</div>
<div class="nav">
<nav>
<ul>
<li>Portfolio</li>
<li>About</li>
<li>Contact</li>
</ul>
</nav>
</div>
</header>
</div>
You could also use javascript which can traverse the DOM better.

Related

Color transition

I'm trying to make a color transition but I don't know how to make the effect that the color will be added gradually without increase size.
a:hover{
background-color:#c0392b;
transition: 1000ms linear;
padding:20px;
<nav class="navigation-in-center">
<ul class="container menu group">
<li>A PROPOS</li>
<li>SERVICES</li>
<li>IDEES</li>
<li>CHEQUES CADEUX</li>
<li>CONTACT</li>
</ul>
</nav>
Your size is increasing due to padding.
Remove the padding and apply transition to the a element, not in it's hover state:
a {
transition: all 1000ms linear;
}
a:hover {
background-color: #c0392b;
}
<nav class="navigation-in-center">
<ul class="container menu group">
<li>A PROPOS</li>
<li>SERVICES</li>
<li>IDEES</li>
<li>CHEQUES CADEUX</li>
<li>CONTACT</li>
</ul>
</nav>
You should add a transition for "background-color" only.
transition: background-color 1000ms linear;
a{
display: inline-block;
padding:20px;
transition: background-color 1000ms linear;
}
a:hover{
background-color:#c0392b;
}
<nav class="navigation-in-center">
<ul class="container menu group">
<li>A PROPOS</li>
<li>SERVICES</li>
<li>IDEES</li>
<li>CHEQUES CADEUX</li>
<li>CONTACT</li>
</ul>
</nav>

How to apply effect just to background image and not text

I'm searching a way to make an css effect but with exception of not applying the effect to the letters and the buttons (Only to the image), so I need create a rule in css. I can't change the order of the things.
With my code, I get something like this.
This is my code, like you can see I applied some effect in css and this is getting applied to all. I only need it for the image.
.myimage01 {
-webkit-transform: scale(1);
transform: scale(1);
-webkit-transition: .3s ease-in-out;
transition: .3s ease-in-out;
}
.myimage01:hover {
-webkit-transform: scale(1.3);
transform: scale(1.3);
}
<li id="armonioso-text-2" class="widget widget_armonioso_text">
<div class="armonioso-textwidget-wrapper armonioso-textwidget-no-paddings">
<!-- Here I'm currently Applying the efect -->
<div class="armonioso-textwidget myimage01" data-style="background-image: url(http:www.myurl.com/image.jpg);padding: 40px 30px ;color: #ffffff;text-align: center;">
<h5>hello world</h5>
<h3>Here how works</h3>
<p>Take a look of new things
<p><a class="btn alt" href="about/index.html" target="_self">About me</a>
</div>
</div>
<!-- Here I'm currently Applying the efect -->
</li>
When I apply the effect apply the effect to the letters (h5, h3, p and the button with btn class)
I don't want the effect for them, only for the background-image.
How can I do?
for transition backgrounds use the property background-size, and use background-position to adjust as fits you better
body {
margin: 0
}
.myimage01 {
background-size: 100%;
background-position:center center;
-webkit-transition: .3s ease-in-out;
transition: .3s ease-in-out;
background-image: url(http://lorempixel.com/1600/900);
padding: 40px 30px;
color: #ffffff;
text-align: center;
}
.myimage01:hover {
background-size: 130%;
}
<li id="armonioso-text-2" class="widget widget_armonioso_text">
<div class="armonioso-textwidget-wrapper armonioso-textwidget-no-paddings">
<!-- Here I'm currently Applying the efect -->
<div class="armonioso-textwidget myimage01">
<h5>hello world</h5>
<h3>Here how works</h3>
<p>Take a look of new things
<p><a class="btn alt" href="about/index.html" target="_self">About me</a>
</div>
</div>
<!-- Here I'm currently Applying the efect -->
</li>
Use background-size for transition:
div {
background-image: url(http://lorempixel.com/400/200/sports/1/);
background-size: 100%;
background-repeat:no-repeat;
background-position:50% 50%;
width:400px;
height:200px;
transition: background-size 200ms linear;
text-align:center;
line-height:200px;
}
div:hover {
background-size: 120%;
}
<div>
Some text
</div>
try to transform the background-size property instead of scaling the whole container.
You can apply transform on background-size, background-position to get the effect on the background image.
.myimage01 {
background-size:100%;
background-position:0px 0px;
-webkit-transform: all;
transform: all;
-webkit-transition: .3s ease-in-out;
transition: .3s ease-in-out;
}
.myimage01:hover {
background-size:140%;
background-position:-50px -50px;
-webkit-transform: all;
transform: all;
}
<li id="armonioso-text-2" class="widget widget_armonioso_text">
<div class="armonioso-textwidget-wrapper armonioso-textwidget-no-paddings">
<!-- Here I'm currently Applying the efect -->
<div class="armonioso-textwidget myimage01" style="background-image: url(http://dummyimage.com/600x200/000/fff);padding: 40px 30px ;color: #ffffff;text-align: center;">
<h5>hello world</h5>
<h3>Here how works</h3>
<p>Take a look of new things
<p><a class="btn alt" href="about/index.html" target="_self">About me</a>
</div>
</div>
<!-- Here I'm currently Applying the efect -->
</li>

How would I apply a transition to a navigation element?

I'm basically trying to add an animation to my navigation so when a user hovers over the links the text color fades in blue, and then fades back out to black after. I've read up on the transition property and watched a few tutorials on Youtube but I can't get it to work when I apply it to my own navigation bar.
Below is a link to my Codepen, if anybody could shed some light on the problem I'd be really appreciative..
Thanks
HTML:
<!-- header starts here -->
<header>
<nav>
<ul>
<li>Home</li>
<li>Contact</li>
<li>About</li>
<li>Service</li>
</ul>
</nav>
</header>
http://codepen.io/Clarkpen/pen/razMWB
Try here:
http://codepen.io/anon/pen/myMrRq
I included a transition on the anchor:
nav ul li a {
transition:all 400ms ease-in;
}
Note it is good practice to add the vendor prefixes:
nav ul li a {
-webkit-transition: all 400ms ease-in-out;
-moz-transition: all 1400ms ease-in-out;
-o-transition: all 400s ease-in-out;
transition: all 400ms ease-in-out;
}
EDIT
I have edited your codepen here to only add the transition to the navigation links:
http://codepen.io/anon/pen/RNZGpL
nav ul{margin:0px;padding:0px;}
nav ul li{float:left;list-style:none;}
nav ul li a{text-decoration:none; padding:15px; color:#666; text-transform:uppercase;transition:ease-in 0.5s;-webkit-transition:ease-in 0.5s;-ms-transition:ease-in 0.5s;-moz-transition:ease-in 0.5s;}
nav ul li a:hover{background:#F00; color:#FFF;}
<nav>
<ul>
<li>Home</li>
<li>About US</li>
<li>Products</li>
<li>Feedback</li>
<li>Contact</li>
</ul>
</nav>
Demo

Links are not working when offcanvas menu enabled

Here's my site:http://vani.valse.com.my/schone_lightings/index.php.
When I use offcanvas menu for mobile version , any links on the page become unclickable. I thought it's something to do with z-index but it doesn't change anything. Can anyone tell me why this happens and how to fix it plz?
My css
.off-canvas-fixed {
-webkit-transition: -webkit-transform 500ms ease;
transition: transform 500ms ease;
height:100%;
}
.move-right > .off-canvas-fixed {
-webkit-transform: translate3d(15.625rem, 0, 0);
transform: translate3d(15.625rem, 0, 0);
height:100%;
}
.left-off-canvas-menu {
-webkit-transform: none;
transform: none;
margin-left: -15.625rem;
height: 100%;
}
.main-section {
padding:45px 0 0;
}
.tab-bar {
width:100%;
}
#media only screen and (orientation:landscape) and (max-width: 64em){
.main-section {
padding:0 0 0 2.8125rem;
}
.off-canvas-fixed {
width:2.8125rem;
height:100%;
background:#333333;
}
section.left-small{
border:none;
box-shadow:none;
}
}
/*remove opacity for mobile*/
#media all and (max-width : 40em)
{
.row { opacity : 1; }
.cart,.search,.myModal,.reveal-modal {margin-top:50px;}
}
My HTML
<!-- Off Canvas Nav ----------------------------------------------------------------------------------------------------->
<div class="off-canvas-wrap">
<div class="fixed off-canvas-fixed hide-for-large-up"> <a class="exit-off-canvas"></a>
<nav class="tab-bar">
<section class="left-small"> <a class="left-off-canvas-toggle menu-icon" href="#"><span></span></a>
</section>
<section class="show-for-portrait right tab-bar-section">
<h1 class="title">Logo</h1>
</section>
</nav>
<aside class="left-off-canvas-menu">
<ul class="off-canvas-list">
<li class="show-for-small">
</li>
<li>home</li>
<li>product</li>
<li>help</li>
<li>contact</li>
<li>login/sign up</li>
</ul>
</aside>
</div>
<div class="inner-wrap"> <a class="exit-off-canvas"></a>
</div>
</div>
EDITED:
I removed opacity control for mobile then the links are working except for the search link at the very top. However I need to remove opacity and make all links working.
/*remove opacity for mobile*/
#media all and (max-width : 40em)
{
/* .row { opacity : 1; } */
.cart,.search,.myModal,.reveal-modal {margin-top:50px;}
}
.off-canvas-fixed class has height:100%; it covered your webpage.

how to make an overlay caption on a liquid container

I am using Foundation framework, and I have a large-block-grid-4 set of images, I would like to have a div as a caption to cover the entire image that is inside a li tag, I have done my CSS and html but since the width of the container changes according to the screen size, I can't get the div properly fit into the li at all times
here is an example of the feature I am trying to do.
http://procreate.si
the HTML
<div class="row">
<div class="large-12 columns">
<ul class="large-block-grid-4">
<li>
<div class="overlay"></div>
<a href="#">
<img src="http://placehold.it/290X290" />
</a></li>
<li><img src="http://placehold.it/290X290" /></li>
<li><img src="http://placehold.it/290X290" /></li>
<li><img src="http://placehold.it/290X290" /></li>
</ul>
</div>
</div>
and the CSS
.overlay {
background:#000;
opacity: 0.8;
height: 100%;
position: absolute;
width: 100%;
-webkit-transition: opacity 0.9s;
-moz-transition: opacity 0.9s;
-ms-transition: opacity 0.9s;
-o-transition: opacity 0.9s;
transition: opacity 0.9s;
}
.overlay:hover {
opacity: 1.0
}
the caption div takes the whole width of the ul , this is not what I intended , what is the solution to this?
many thanks