For a new webdesign I made two 50% width div's that slide over on hover. When hovering on the left 'slide' div, I want the right 'logo' div to hide (display:none) and vice versa, but it just won't work. What am I missing here? Any help would be much appreciated!
body {
background:black;
}
.slide {
position:absolute;
top:0;
bottom:0;
width:50%;
-webkit-transform:skew(-15deg);
-moz-transform:skew(-15deg);
-ms-transform:skew(-15deg);
-o-transform:skew(-15deg);
transform:skew(-15deg);
z-index:2;
}
.slide:hover {
width:60%;
z-index:80;
}
.slide#left {
left:0;
}
.slide#right {
right:0;
}
.wrap {
width:100%;
height:100%;
position:absolute;
overflow:hidden;
z-index:2;
}
.inner {
width:100%;
height:100%;
-webkit-transform:skew(15deg) scale(1.5);
-moz-transform:skew(15deg) scale(1.5);
-ms-transform:skew(15deg) scale(1.5);
-0-transform:skew(15deg) scale(1.5);
transform:skew(15deg) scale(1.5);
opacity:0.6;
position:absolute;
}
.slide:hover .inner {
opacity:0.9;
}
.inner#left {
background:url(//savado.nl/new/key.jpg) no-repeat center center;
-webkit-background-size:cover;
-moz-background-size:cover;
-ms-background-size:cover;
-o-background-size:cover;
background-size:cover;
}
.inner#right {
background:url(//savado.nl/new/code2.jpg) no-repeat center center;
-webkit-background-size:cover;
-moz-background-size:cover;
-ms-background-size:cover;
-o-background-size:cover;
background-size:cover;
}
.inner#left:hover .logo#right {
display:none;
}
.inner#right:hover .logo#left {
display:none;
}
.slide .logo {
position:absolute;
z-index:99;
top:50%;
height:30%;
}
.logo img {
height:100%;
}
.logo#left {
right:0;
-webkit-transform:translateX(50%) translateY(-50%) skew(15deg);
-moz-transform:translateX(50%) translateY(-50%) skew(15deg);
-ms-transform:translateX(50%) translateY(-50%) skew(15deg);
-o-transform:translateX(50%) translateY(-50%) skew(15deg);
transform:translateX(50%) translateY(-50%) skew(15deg);
}
.logo#right {
left:0;
-webkit-transform:translateX(-50%) translateY(-50%) skew(15deg);
-moz-transform:translateX(-50%) translateY(-50%) skew(15deg);
-ms-transform:translateX(-50%) translateY(-50%) skew(15deg);
-o-transform:translateX(-50%) translateY(-50%) skew(15deg);
transform:translateX(-50%) translateY(-50%) skew(15deg);
}
div {
-webkit-transition:opacity 0.6s ease, width 0.6s ease, z-index 0.6s ease;
-moz-transition:opacity 0.6s ease, width 0.6s ease, z-index 0.6s ease;
-ms-transition:opacity 0.6s ease, width 0.6s ease, z-index 0.6s ease;
-o-transition:opacity 0.6s ease, width 0.6s ease, z-index 0.6s ease;
transition:opacity 0.6s ease, width 0.6s ease, z-index 0.6s ease;
}
<div class='slide' id='right'>
<div class='wrap'>
<div class='inner' id='right'></div>
</div>
<div class='logo' id='right'>
<img src='//savado.nl/new/logo.png' />
</div>
</div>
<div class='slide' id='left'>
<div class='wrap'>
<div class='inner' id='left'></div>
</div>
<div class='logo' id='left'>
<img src='//savado.nl/new/logo.png' />
</div>
</div>
And here is the [JSFIDDLE][1]!
Thanks in advance!
[1]: http://jsfiddle.net/NZXeT/
That is because your CSS
.inner#left:hover .logo#right {
display:none;
}
.inner#right:hover .logo#left {
display:none;
}
Will never be valid, there is no .logo#right INSIDE your .inner#left:hover element, it only contains a .logo#left. The same with the other.
You will have to re-think your design for this to work, I do not see why you need two logo's, why not just have one logo that slides one side or the other? Why have to hide them?
So your first issue is that you have multiple elements with the same ID. That's going to make things confusing (and invalid), so stick with unique IDs.
Second, CSS has the limitation of only being able to affect the element in the rule, siblings after that element, or children of that element. This means that if you want to stick with pure CSS you're going to need to get slightly hacky.
If you want to use javascript/jQuery, it's basically a one-liner fix.
If you want to stick with pure HTML+CSS you can use the sibling selector ~ to match the other slide. Try this:
.slide#right:hover ~ .slide#left {display: none;}
You'll see the left side hide when you hover the right just like intended! However, doing the opposite won't work :( This is because the left element is after the right in the markup. However, you can "cheat" and add a hidden "trigger" over the left side. If you add an element before .slide#right that is exactly the same size and shape of .slide#left, then add the same rule as I have here but replace #right with #lefttrigger it should work.
Does that make sense?
Related
hi i want to make a effect like this to my div on a hover:
website with the effect, hover over the people div's to see
I have tried to make a grid but I am strugling to get the hover effect on top of the div.
my codepen link, need the hover on the blocks
You'll need a container div and at least one foreground div to cover the background (could be just an image). Then you'll want to target the parent on hover and change the foreground child. I used transform instead of animating a position property because it's more performant.
.card{
position:relative;
width:200px;
height:200px;
border:1px solid blue;
overflow:hidden;
}
.card > div{
height:100%;
width:100%;
}
.card .foreground{
position:absolute;
top:0;
left:0;
right:0;
bottom:0;
transform:translateX(100%);
background-color:blue;
transition:.5s ease;
}
.card:hover .foreground{
transform:translateX(0);
}
<div class="card">
<div class="foreground"></div>
<div class="background"></div>
</div>
You can attach styles to a div by using the :hover keyword.
Example, you want to change some effect on the div on hover:
div:hover {
background-color: black;
}
You want to change some effect on a child, on parent hover
div:hover .child {
background-color: black;
}
EDIT
Ok, check the class changes when you force hover on their page, their original element has these styles:
z-index: 200;
content: "";
height: 263px;
width: 102px;
background-color: #91c6c2;
display: inline-block;
position: absolute;
top: 0px;
right: -50px;
-webkit-transform: skew(21deg);
transform: skew(21deg);
-webkit-backface-visibility: hidden;
-webkit-transition: right 0.5s;
transition: right 0.5s;
On hover, they just change the elements "right", to 80px, which makes it float in via the mentioned transition, "transition: right 0.5s".
you require a overlay effect on hover of a div.
Please refer this link
<div id="overlay">
<span id="plus">+</span>
</div>
CSS
#overlay { background:rgba(0,0,0,.75);
text-align:center;
padding:45px 0 66px 0;
opacity:0;
-webkit-transition: opacity .25s ease;
-moz-transition: opacity .25s ease;}
#box:hover #overlay {
opacity:1;}
#plus { font-family:Helvetica;
font-weight:900;
color:rgba(255,255,255,.85);
font-size:96px;}
Found this in google search and also lots of plugins are avila
This may not be the most efficient way but it was most definitely the easiest that I've found. You can add the absolute position to the hidden div to make it on top of the image if you so choose!
HTML:
<div id='backgroundImg' onmouseover="hoverOver('show');" onmouseout="hoverOver('hide');">
<div id='hiddenDiv'>
</div>
<img src='myImage.png'>
</div>
Javascript:
<style>
function hoverOver(type) {
if (type=='show') {
document.getElementById('hiddenDiv').style.display='inherit';
} else {
document.getElementById('hiddenDiv').style.display='none';
}
}
</style>
I'm having difficulty trying to get an image overlay and image zoom to appear at the same time on mouse hover. For some reason, the overlay disappears when I added the image zoom. It seems like one webkit transition cancels the other out. Either the zoom will work or the overlay will appear but not both. Any help is greatly appreciated, I've been researching for hours and can't seem to figure it out.
HTML Code:
<div class="image_wrap">
<div class="caption">
<i class="fa fa-search-plus" aria-hidden="true"></i>
<p class="heading">
Resort Website
</p>
</div>
<img src="css/images/resort.jpg" alt="resort" class="portfolio-pic">
</div>
CSS Code:
.image_wrap{
position:relative;
}
.image_wrap .caption{
position:absolute;
width:100%;
height:100%;
opacity: 0;
text-align:center
display:inline-block;
background: linear-gradient(rgba(51, 153, 170, 0.9), rgba(51, 153, 170, 0.8));
-webkit-transition:all .4s ease-in-out;
transition:all .4s ease-in-out
}
.image_wrap .caption:hover{
opacity: 1;
}
.image_wrap .caption img {
position:relative;
-webkit-transition:all .4s linear;
transition:all .4s linear;
}
.image_wrap .caption:hover img {
-ms-transform:scale(1.2);
-webkit-transform:scale(1.2);
transform:scale(1.2);
}
I detect two problems on your code, change this:
.image_wrap .caption:hover img {
-ms-transform:scale(1.2);
-webkit-transform:scale(1.2);
transform:scale(1.2);
}
For this:
.image_wrap:hover img {
-ms-transform: scale(1.2);
-webkit-transform: scale(1.2);
transform: scale(1.2);
z-index:8;
}
You can answer why. Because your image not inside .caption and you didn't declare the z-index (caption on the image).
Declare the z-index on caption too.
.image_wrap:hover .caption {
opacity: 1;
z-index:9999;
}
Here is the link for jsfiddle where I test our code: link
I have two images:one is supposed to be like a border and it would rotate on hover,the other one is supposed to be inside the first image that rotates.How can i put the second image inside the first?Here is my code and jsfiddle...
<div class="col-xs-4" style="text-align:center;margin-top:20px;background:black;">
<img class="img-responsive rotate" src="http://s21.postimg.org/s70s6ioyb/Okvir_rotirajuci.png" style="display:inline-block;"/>
<img class="img-responsive" src="http://s23.postimg.org/d0uos0jvb/E_mail.png" style="display:inline-block;"/>
</div>
My css...
.rotate{
-moz-transition: all 0.6s ease-in-out;
-webkit-transition: all 0.6s ease-in-out;
-o-transition: all 0.6s ease-in-out;
-ms-transition: all 0.6s ease-in-out;
transition: all 0.6s ease-in-out;
}
.rotate:hover {
-moz-transform: rotate(360deg);
-webkit-transform: rotate(360deg);
-o-transform: rotate(360deg);
-ms-transform: rotate(360deg);
transform: rotate(360deg);
}
JSFIDDLE
I had to use a couple of nested elements to achieve all three goals:
Spinning border and envelope icon overlap and align together.
Image pair is centered horizontally.
Image pair size is responsive.
Explanation
The element div.image_wrap is a centered child of div.container that provides a container for both images. It's width is 100% of div.container, but no more than 42px (the width of your images).
The element div.image_height_prop gives div.image_wrap (and therefore div.container) height. Since the images inside are positioned absolutely (so that they overlap), they have no height and will not prop open their container. div.image_height_prop has padding-top set to 100% of its parents width, essentially making a responsive square strut.
The images are positioned absolutely on top of one another, with the "border" last in the DOM so that it will be on top of the stacking order (for hover).
HTML
<div class="col-xs-4 container">
<div class="image_wrap">
<div class="image_height_prop">
<img class="icon" src="http://s23.postimg.org/d0uos0jvb/E_mail.png" />
<img class="rotate" src="http://s27.postimg.org/x4d8qxe73/square.png" />
</div>
</div>
</div>
CSS
div.container {
text-align:center;
background:black;
margin-top:20px;
}
div.image_wrap {
display:inline-block;
max-width:42px;
width:100%;
}
div.image_height_prop {
position:relative;
width:100%;
padding-top:100%;
height:0;
}
div.image_wrap img {
position:absolute;
top:0;
left:0;
width:100%;
}
img.rotate {
-moz-transition: all 0.6s ease-in-out;
-webkit-transition: all 0.6s ease-in-out;
-o-transition: all 0.6s ease-in-out;
-ms-transition: all 0.6s ease-in-out;
transition: all 0.6s ease-in-out;
}
img.rotate:hover {
-moz-transform: rotate(360deg);
-webkit-transform: rotate(360deg);
-o-transform: rotate(360deg);
-ms-transform: rotate(360deg);
transform: rotate(360deg);
}
Working Example
As mentioned by #chiliNUT, the box in the "border" image is off-center. I centered the image and and re-uploaded it. As an alternative, you could add a 1px left margin to the "envelope" image to adjust for the box being off-center.
img.rotate {
margin-left:1px;
}
An example of that
This will do it:
Wrap the images in an inline-block div.
Remove the inline-block style from both images.
Make the first image position:absolute, which will impose it onto the second image.
Leave the second image's style alone, the img element defaults to display:inline which is what we want.
See my update to your fiddle
http://jsfiddle.net/T8Pjh/17/
<div class="col-xs-4" style="text-align:center;margin-top:20px;background:black;position:relative;">
<div style=display:inline-block;>
<img class="img-responsive rotate" src="http://s21.postimg.org/s70s6ioyb/Okvir_rotirajuci.png" style="position:absolute;" />
<img class="img-responsive" src="http://s23.postimg.org/d0uos0jvb/E_mail.png" />
</div>
</div>
I have the following codepen, this is a basic positioned label with the number and marker text:
<span href="#" class="part-marker">
1<span> marker text</span>
</span>
How can I get it to slide out on hover using css3 transitions? I've tried using this with no success??
See below a simplified version- the crux here being that you cant make a transition on properties that don't scale, so where you have the element going from display:none t inline-block it simply goes from hidden to shown as there are no intermediary points. What you can do instead is use a combination of max-width and overflow as outlined below.
Demo Fiddle
HTML
<div> <a href='#'>1</a>
<span>Label</span>
</div>
CSS
a {
display:inline-block;
background:blue;
color:white;
padding:0 5px;
}
div {
position:relative;
}
div span {
position:absolute;
display:inline-block;
max-width:0;
overflow:hidden;
transition:all 1s ease-in;
}
a:hover+span {
max-width:100%;
}
Take a look at this code:
HTML
<a href="#" class="marker-label" text="marker text">
1
</a>
CSS
.marker-label {
display:block;
background:blue;
color:white;
padding:4px 8px;
font-size:1em;
line-height:1;
position:relative;
-webkit-transition: all 1s ease-in-out;
-moz-transition: all 1s ease-in-out;
width:10px;
}
.marker-label:hover {
width:80px;
}
.marker-label:after {
content:attr(text);
-webkit-transition: all 1s ease-in-out;
-moz-transition: all 1s ease-in-out;
position:absolute;
left:-100px;
}
.marker-label:hover:after {
left:20px;
}
And here is a FIDDLE
You can use a negative text-indent too : http://codepen.io/anon/pen/xalDc/
span {
text-indent:-150px;
overflow:hidden;
display:inline-block;/* triggers layout */
transition: all 1s ease-in-out;
/* position:absolute ; not needed since a is already so */
}
&:hover {
span {
text-indent:0;
}
}
Hello I am using the target method to manipulate different div styles, for the first "link_one" everything is working, while I have only one link, the question is how to make it work for "link_two" ? So link_two will do the second part of the css ? What is more important here is that each link is maniluplating 2 different classes in which link one and two one of the class is the same.
link_one
<div id="sections">
<div id="link_one">info</div>
<div id="link_two">info</div>
</div>
/* link one code */
#sections:target #link_one{
height:90px;
background:#333;
transition:all 1s ease;
}
#sections:target .rslides {
height:0px;
transition:all 1s ease;
}
/* link two code */
#sections:target #link_two{
height:90px;
background:#333;
transition:all 1s ease;
}
#sections:target .rslides {
height:0px;
transition:all 1s ease;
}
One way to apply the target selector would be:
for this HTML
link_one
<br>
link_two
<div id="sections1"></div>
<div id="sections2"></div>
<div id="link_one" class="link">info</div>
<div id="link_two" class="link">info</div>
Set this CSS
.link {
height: 20px;
transition:all 1s ease;
}
#sections1:target ~ #link_one{
height:90px;
background:#333;
}
#sections2:target ~ #link_two{
height:90px;
background:#333;
}
fiddle