I started a project in Notepad++ and I would like to create a slider on hover while using CSS. The problem is that I do not know if my picture (which I wanted to create a slider with) needs to be separated in 2 images or 1 merged picture. I also don't know if translate3d works in notepad++.
Here's what my HTML looks like:
<div class="college">
<img src="image.png" />
and here's my current CSS:
body {
background: url("anotherimage.png") 33em 0% fixed no-repeat;
background-color: rgb(0,85,170);
}
.college {
margin-left: 100px;
margin-top: 325px;
overflow: hidden;
}
.college img {
}
.college img:hover {
}
edit
hello again, after we've found out about my problem with hovering sliding images, i managed to make my own ligns of codes but now im stuck into another problem, while i was douing my code my images were going behind the background which i liked it very much but when i finished all of it, it stopped douing it ,i've tried using overflow: hidden and postion: absolute but i don't really get how it works especially since when i search what their fonction does. and i thought i was douing right but it seems it doesn't change anything at all,
so i would like to know how i manage to make my moving pictures to go out of the screen/ hide inside the background.
here what my css looks like
` .college .image {
margin-left: 100px;
margin-top: 475px;
position: absolute
}
.college .imagesecond {
transform: translate(0px,500px);
transition: transform 1s ease-in-out 0.2s;
border-radius: 8px;
overflow: hidden
}
.college:hover > .imagesecond{
transform: translate(0,-200px);
}
.lycee .image {
margin-left: 700px;
margin-top: 500px;
position: absolute
}
.lycee .imagefourth{
transform: translate(0px,500px);
transition: transform 0.9s ease-in-out 0.2s;
border-radius: 8px;
overflow: hidden
}
.lycee:hover > .imagefourth{
transform: translate(0,-500px);
}
.formation .image{
margin-left: 1250px;
margin-top:510px;
overflow: hidden;
}
.formation .imagesixth{
transform: translate(0px,100px);
transition: transform 1s ease-in-out 0.2s;
border-radius: 8px;
overflow: hidden
}
.formation:hover > .imagesixth{
transform: translate(0 ,-75
0px);`
here is my html
<div class="saintemarie">
<a href="">
<div class="college">
<img class="image imagefirst" src="choixcollege.png" />
<img class="image imagesecond" src="pepepls.gif"/>
</div>
</a>
<a href="lyceesaintemarie.html">
<div class="lycee">
<img class="image imagethird" src="choixlyceepro.png" />
<img class="image imagefourth" src="pepepls.gif" />
</div>
</a>
<a href="c&fsaintemarie.html">
<div class="formation">
<img class="image imagefifth" src="choix
centre&formation.png" />
<img class="image imagesixth" src="pepepls.gif" />
</div>
</div>
</a
I'm not fully sure what you're asking but is this what you're wanting? If so you're more interested in transitions or animations, hover within the blue border
https://jsfiddle.net/gevfeqk9/24/
.college {
margin: auto;
overflow: hidden;
border: 1px solid blue;
}
.college .image-1{
transform: translate(-280px,0);
transition: transform 1s ease-in-out 0s;
}
.college .image-2{
transform: translate(-560px,0);
transition: transform 1s ease-in-out 0s;
}
.college:hover .image-1,.college:hover .image-2{
transform: translate(0,0);
}
Related
I'm having odd behavior where circular pictures are changing to square on desktop and mobile. This only seems to be happening on safari, and it only happens when I add a CSS transition. Here's the website:
https://shmoss.github.io/Gibbs-Lab/people.html
If you view on mobile and click on a photo, it will change to a square. Here's the code:
<div class="py-5 text-center text-info background-info" style="">
<div class="container" id="people-container">
<div id="parent" class="row">
<!-- Lead Scientists -->
<div class="col-6 col-md-3 p-4 holly-gibbs lead-scientist">
<div class="img-holder">
<a style='color:none'href="holly-gibbs.html"><img class="img-fluid d-block mx-auto" src="bio_img/holly_gibbs_bio_new.png" alt="Card image cap" width="200">
</a>
</div>
<div class="bio-holder">
<a style='color:none'href="holly-gibbs.html">
<h4 class="people_name"> <b>Holly Gibbs</b> </h4>
<p class="mb-0">PROFESSOR AND DIRECTOR OF GLUE LAB</p>
</a>
</div>
</div>
<div class="col-6 col-md-3 p-4 lead-scientist">
<div class="img-holder">
<a style='color:none'href="tyler-lark.html"><img class="img-fluid d-block mx-auto " src="bio_img/tyler_lark_bio.png" alt="Card image cap" width="200">
</a>
</div>
<div class="bio-holder">
<a style='color:none'href="tyler-lark.html">
<h4 class="people_name"> <b>Tyler Lark</b> </h4>
<p class="mb-0">LEAD SCIENTIST</p>
</a>
</div>
</div>
</div>
</div>
/* ------------------------------People Page ------------------------------*/
/* container for people photos */
#people-container {
padding-top:10px;
}
/* Bio photo */
.img-holder {
max-width: 200px;
max-height: 200px;
overflow: hidden !important;
margin:0 auto
}
/* Bio info container (name, title) */
.bio-holder {
padding-top:10px;
}
/* Bio title */
.mb-0 {
color:#004869 !important;
font-size:14px;
font-weight:500 !important;
text-transform: uppercase
}
/* Bio image container */
.img-holder {
box-shadow: 0px 3px 15px rgba(0,0,0,0.2);
border-radius:50%
}
/* Scaling bio image on hover */
/* THIS CAUSES THE ISSUE! */
.img-fluid.d-block.mx-auto:hover {
-webkit-transform: scale(1.1);
-webkit-transition: all 0.125s ease-in-out 0s;
-moz-transition: all 0.125s ease-in-out 0s;
-ms-transition: all 0.125s ease-in-out 0s;
-o-transition: all 0.125s ease-in-out 0s;
transition: all 0.125s ease-in-out 0s;
}
.img-fluid.d-block.mb-3.mx-auto:focus {
-webkit-transform: scale(1.1);
-webkit-transition: all 0.125s ease-in-out 0s;
-moz-transition: all 0.125s ease-in-out 0s;
-ms-transition: all 0.125s ease-in-out 0s;
-o-transition: all 0.125s ease-in-out 0s;
transition: all 0.125s ease-in-out 0s;
}
I can't seem to figure out what's going on, maybe conflicting CSS somewhere?
I can reproduce, here is a minimal example, (please next time try to make yours as minimal)
.round {
width: 200px;
height: 200px;
overflow: hidden;
border-radius: 50%;
}
.inner {
transition: all 1s;
background: radial-gradient(red, green);
height: 100%;
cursor: pointer;
}
.inner:hover {
transform: scale(2);
}
<div class=round >
<div class=inner ></div>
</div>
This is a Safari bug, your code is fine [should work], and you should report the issue at https://bugs.webkit.org/.
The problem seems to affect only the software rendering, if we force using the GPU rendering, e.g by applying a 0px translateZ on the container, it works as expected:
.round {
width: 200px;
height: 200px;
overflow: hidden;
border-radius: 50%;
transform: translateZ(0px); /* force GPU rendering */
}
.inner {
transition: all 1s;
background: radial-gradient(red, green);
height: 100%;
cursor: pointer;
}
.inner:hover {
transform: scale(2);
}
<div class=round >
<div class=inner ></div>
</div>
So in your code you'd add this on the .img-holder rule.
However note that you probably don't need the prefixes for these properties anymore, and that even if you do need them, you should always add the unprefixed ones too, at the end. Currently your code only has -webkit-transform set, not the unprefixed one. This particular case works, but on some property you'll get different behaviors when the prefixed version is being chosen over the unprefixed one.
I think you need to clear your cache cos I can't notice it here
Tried on a OnePlus with both Chrome and Mozilla, it seems exactly like on desktop.
CSS has a habit of bugging out, try to clear cache line Nasiru stated or try a different browser just for testing
So, I was trying to get an image to, when hovered over, spin 360 degrees and scale up by 1.4, all with its centre staying in place. I tried this:
.logo img[data-v-4fbac4e1] {
width: 50px;
height: 50px;
content: url(https://i.imgur.com/txz1IXI.png);
transition: width 2.0s, height 2.0s, transform 2.0s;
}
with this:
.logo img[data-v-4fbac4e1]:hover{
width: 65px;
height: 65px;
transform: rotate(360deg);
}
and it works fine, but it moves off-centre as it expands. How do I make sure the width and height increase from the centre so it stays in the same place? Sorry if this seems elementary, I'm new to CSS.
Edit: the part of the HTML I'm using looks like this:
<a data-v-4fbac4e1 href="/home" class="logo">
<img data-v-4fbac4e1 src="/img/icons/icon.svg">
</a>
If more is required I can add it, but this is the HTML for the image I'm trying to transform.
Since I'm not entirely sure what you mean, point to which is your culprit and we'll get you sorted out but here's some examples of the differences between techniques.
img, div {
display: inline-block;
margin: 1rem;
height: 10rem;
width: 10rem;
}
.fancy-img1, .fancy-img3 {
object-fit: cover;
outline: red 2px solid;
}
.fancy-img2, .fancy-img4 {
background: url(https://picsum.photos/200) no-repeat center center / cover;
outline: blue 2px solid;
}
/* grow by height value change transition */
.fancy-img1 {
transition: transform .5s, height .5s;
}
.fancy-img2 {
transition: transform .5s, height .5s;
}
.fancy-img1:hover, .fancy-img2:hover {
transform: rotate(360deg);
height: 15rem;
}
/* Scale with transition */
.fancy-img3 {
transition: transform .5s;
}
.fancy-img3:hover {
transform: scaleY(1.5) rotate(360deg);
}
/* Scale with keyframes */
#keyframes spinGrow {
to { transform: scaleY(1.5) rotate(360deg); }
}
.fancy-img4:hover {
animation: spinGrow .5s forwards;
}
<h2>Are you talking about transition height which cause the jumpy effect?</h2>
<img class="fancy-img1" src="https://picsum.photos/200">
<div class="fancy-img2"></div>
<h2>Or actually scale so it remains in its original position?</h2>
<img class="fancy-img3" src="https://picsum.photos/200">
<div class="fancy-img4"></div>
I am having trouble with stacking images in HTML/CSS for some reason. I have three slides, stacked on top of each other, slightly offset so that they peak out from under one another, bottom-to-top. The animation I am using should allow them to slide over to the right when I hover on the edge that is "peaking out." It works perfectly with two images, but for some reason, when I added a third to the pile, the animation for the bottom two stopped working. NO CLUE why this won't work.
Here is the code:
#containerContainer {
position: relative;
}
#instashContainer,
#wisdomCotainer,
#visContainer {
position: absolute;
height: 744px;
width: 1860px;
overflow: hidden;
}
#instashContainer img,
#wisdomContainer img,
#visContainer img {
opacity: .7;
position: absolute;
left: 0px;
top: 0px;
transform: translate3d(-1600px, 0px, 0px);
transition: transform .6s ease-in-out;
}
#instashContainer img:hover,
#wisdomContainer img:hover,
#visContainer img:hover {
transform: translate3d(0px, 0px, 0px);
}
<div id="containerContainer">
<!--Inspiration Slidepage-->
<div id="instashContainer">
<img src="instash_slidepage.jpg" height=744 width=1820>
</img>
</div>
<!--Wisdom Slidepage-->
<div id="wisdomContainer">
<img src="wisdom_slidepage.jpg" height=744 width=1780>
</img>
</div>
<!--Visualization Slidepage-->
<div id="visContainer">
<img src="visualization_slidepage.jpg" height=744 width=1740>
</img>
</div>
</div>
When I add the third image, on top of the other two, the animation for the other two stops working, but the animation for the top image works (i.e. it slides to the right). When I remove the top image, but change nothing else, the animation for the other two works again.
Why? Also, how can I add this third image without impacting the animation of the other two images?
Problem
you have a typo here: #wisdomCotainer, should be#wisdomContainer
Notes
don't use HTML tags width/height, use instead CSS
<img> tag are self-closed tags, therefore don't need </img>
and you can simplify your CSS in this case by using the direct child selector >
#containerContainer {
position: relative;
}
#containerContainer > div {
position: absolute;
height: 744px;
width: 1860px;
overflow: hidden;
}
#containerContainer > div img {
opacity: .7;
position: absolute;
left: 0px;
top: 0px;
transform: translate3d(-1600px, 0px, 0px);
transition: transform .6s ease-in-out;
height: 744px;
width: 1820px;
}
#containerContainer > div img:hover {
transform: translate3d(0px, 0px, 0px);
}
<div id="containerContainer">
<!--Inspiration Slidepage-->
<div id="instashContainer">
<img src="//lorempixel.com/1280/744" />
</div>
<!--Wisdom Slidepage-->
<div id="wisdomContainer">
<img src="//lorempixel.com/1280/744" />
</div>
<!--Visualization Slidepage-->
<div id="visContainer">
<img src="//lorempixel.com/1280/744" />
</div>
</div>
You've got a typo error here :
#instashContainer, #wisdomCotainer, #visContainer {
}
Should be #wisdomContainer instead.
I have 2 images on top of each other, positioned absolute, in my example they are square but in my real project they are pngs with some transparency in the borders so the one in the back needs to be hidden until it appears on hover.
My problem is I need the transition to have some kind of delay so that the back pic appears a bit before the one on top so you don't see the background in between. I have made a fiddle to illustrate this:
http://jsfiddle.net/L21sk0oh/
You can clearly see the red from the background, that shouldn't happen. Also there is some weird moving going on, I haven't noticed this in my actual project.
Also my HTML:
<div class="product1">
<img class="active" src="http://lorempixel.com/400/200/sports" alt="">
<img class="inactive" src="http://lorempixel.com/400/200/" alt="">
</div>
And my css:
body{
background: red;
}
.product1{
position: relative;
width: 400px;
height: 200px;
}
img{
position: absolute;
top:0;
left:0;
}
.product1 img.active{
transition: all 1s ease-in-out;
opacity: 1;
}
.product1 img.inactive{
transition: all 1s ease-in-out;
opacity: 0;
}
.product1:hover img.active{
opacity: 0;
}
.product1:hover img.inactive{
opacity: 1;
}
You could specify a value for the transition-delay property.
In this case, I added a 1s delay to the transition shorthand of .product1 img.active:
Updated Example
.product1 img.active {
transition: all 1s 1s ease-in-out;
opacity: 1;
}
The above is equivalent to:
.product1 img.active{
transition: all 1s ease-in-out;
transition-delay: 1s;
opacity: 1;
}
Make sure you're adding the transition shorthand properties in the correct order.
I have these social media icons, when the mouse hovers on one icon its should fade into a other icon. I thought of something like this:
HTML:
<div class="socials">
<img src="../images/fb.png" id="fb1" />
<img src="../images/fb-hover.png" id="fb2" />
<img src="../images/twitter.png" id="twitter1" />
<img src="../images/twitter-hover.png" id="twitter2" />
<img src="../images/insta.png" id="insta1"/>
<img src="../images/insta-hover.png" id="insta2" />
</div>
CSS:
/*This is for letting them stack on each other*/
#fb2, #twitter2, #insta2 {
display:none;
position:absolute;
}
/*Fade animation*/
#fb1:hover, #twitter1:hover, #insta1:hover {
opacity: 0.0;
transition: opacity .55s ease-in-out;
-moz-transition: opacity .55s ease-in-out;
-webkit-transition: opacity .55s ease-in-out;
}
Or check this jsfiddle.
The fading out works correctly. But the 'background' image (so the '...-hover.png' image) won't show up. How do I make this work?
Thanks!
If you set display to block on your #fb2, #twitter2, and #insta2, you can see the problem - it's the positioning. In your solution you would need to absolutely position each hover icon under the normal icon. I don't think it can be flexible.
So, I propose a more flexible solution.
Introduce this syntax:
<div class="socials">
<div class="icon">
<img src="http://sillyquark.com/images/fb.png" class="normal" />
<img src="http://sillyquark.com/images/fb-hover.png" class="hover" />
</div>
<div class="icon">
<img src="http://www.sillyquark.com/images/twitter.png" class="normal" />
<img src="http://www.sillyquark.com/images/twitter-hover.png" class="hover" />
</div>
<div class="icon">
<img src="http://www.sillyquark.com/images/insta.png" class="normal" />
<img src="http://www.sillyquark.com/images/insta-hover.png" class="hover" />
</div>
</div>
Put each icon in a div with a class of of .icon and inside put two images.
Set the .icon div's position to relative to allow absolute positioning relative to the .icon, instead of the body element. Set each icon's top and left to 0px, and add transitions to all images. Also, add width to .icon and img.
.icon{
float: left;
position: relative;
width: 45px;
height: 45px;
padding: 20px;
}
.icon img{
transition: opacity .55s ease-in-out;
-moz-transition: opacity .55s ease-in-out;
-webkit-transition: opacity .55s ease-in-out;
opacity: 1.0;
position: absolute;
width: 45px;
top: 0;
left: 0;
}
This is how you switch opacities. In normal conditions, set .icon .normal's opacity to 1.0, and .icon .hover's opacity to 0.0. On hover, do the oposite.
.icon .hover { opacity: 0.0; }
.icon:hover .hover { opacity: 1.0; }
.icon:hover .normal { opacity: 0.0; }
Check out this fiddle for the demo http://jsfiddle.net/uUk6N/3/