I know this has been asked quite often, but no solution seems to apply to my situation. I imagine it's something simple that I'm not seeing. Hopefully someone can point me in the right direction.
The Problem
I have a vertical stack of icons that remain to the left of the page as one scrolls down. Everything appears to work, except that the containing divs won't shrink to their content, which prevents users from interacting with part of the interface:
Notice that the Div expands well beyond the image it contains. This interferes with selecting the radio buttons. Here's the markup:
.navStack {
display: table;
position: fixed;
top: 50%;
-webkit-transform: translateY(-50%);
-ms-transform: translateY(-50%);
transform: translateY(-50%);
margin-left: -5%;
}
.navStack div {
width: auto;
}
.navIcons {
transition: all 0.3s ease;
width: auto;
max-Width: 10%;
max-Height: 10%;
margin: 4px 0;
-webkit-filter: brightness(100%);
filter: brightness(100%);
cursor: pointer;
display: inline-block;
}
.navIcons:hover {
transform: scale(1.5);
-webkit-filter: brightness(70%);
filter: brightness(70%);
-webkit-transition: all 1s ease;
-moz-transition: all 1s ease;
-o-transition: all 1s ease;
-ms-transition: all 1s ease;
transition: all 1s ease;
}
<div class='navStack'>
<div>
<img class='navIcons' title='Definition' src="https://i.stack.imgur.com/fadxm.png" alt="" />
</div>
<div>
<img class='navIcons' title='Example' src="https://i.stack.imgur.com/fadxm.png" alt="" />
</div>
</div>
Things I've tried
Display: inline-block / Display: table are the most common solutions. Placing them on 'navStack' does nothing. Placing inline-block on 'navStack div' gets me this:
Display: inline - on 'navStack' there's no response; on 'navStack div' this:
Placing a width doesn't do anything.
Inline-Flex on 'navStack div' gets the same as the above; on 'navStack' in gets me this:
width: min-content - whether it's 'navStack' or 'navStack div', the images completely disappear when applying this.
Per one comment, I've played with max-width/height in'navIcons' and added it to 'navStack div' to look like this:
.navStack div {
max-height: 10%;
max-width: 10%;
border: 1px solid;
}
.navIcons {
transition: all 0.3s ease;
width: auto;
max-width: 100%;
max-height: unset;
/* max-Width: 10%;
max-Height: 10%; */
margin: 4px 0;
-webkit-filter: brightness(100%);
filter: brightness(100%);
cursor: pointer;
display: inline-block;
}
<div class='navStack'>
<div>
<img class='navIcons' title='Definition' src="https://i.stack.imgur.com/fadxm.png" alt="" />
</div>
<div>
<img class='navIcons' title='Example' src="https://i.stack.imgur.com/fadxm.png" alt="" />
</div>
</div>
Here's the result:
Progress
There has been progress thanks to the kind help of people below. With the latest CSS (last CSS above), the 'navStack div' elements are not extending anymore, however, the 'navStack' is:
The solution to this was to apply sizing to both the parent div, its children, and the images.
Specifically, I've applied to 'navStack' a 'max-Width: 10%', to 'navStack div' a max-height: 40%; and max-width: 40%;, and to 'navIcons' width: auto; max-width: 100%; max-height: unset;
The final markup looks like this:
.navStack {
position: fixed;
top: 50%;
-webkit-transform: translateY(-50%);
-ms-transform: translateY(-50%);
transform: translateY(-50%);
margin-left: -5%;
max-width: 10%;
}
.navStack div {
max-height: 40%;
max-width: 40%;
}
.navIcons {
transition: all 0.3s ease;
width: auto;
max-width: 100%;
max-height: unset;
margin: 4px 0;
-webkit-filter: brightness(100%);
filter: brightness(100%);
cursor: pointer;
display: inline-block;
}
<div class='navStack'>
<div>
<img class='navIcons' title='Definition' src="https://i.stack.imgur.com/fadxm.png" alt="" />
</div>
<div>
<img class='navIcons' title='Example' src="https://i.stack.imgur.com/fadxm.png" alt="" />
</div>
</div>
I see you've already answered your own question, but I will throw mine in nonetheless. I believe you are seeing things more complicated than they need to be.
By simply specifying the max-width on your navstack, the rest of the elements should follow when you set them to a width of 100%, giving the following markup :
.navStack {
position: fixed;
top: 50%;
-webkit-transform: translateY(-50%);
-ms-transform: translateY(-50%);
transform: translateY(-50%);
max-width: 10%;
}
.navStack div {
width: 100%;
}
.navIcons {
transition: all 0.3s ease;
width: 100%;
margin: 4px 0;
-webkit-filter: brightness(100%);
filter: brightness(100%);
cursor: pointer;
display: inline-block;
}
Use This Code:
<style>
.navStack {
display: table;
position: fixed;
top: 50%;
-webkit-transform: translateY(-50%);
-ms-transform: translateY(-50%);
transform: translateY(-50%);
margin-left: 0;
}
.navStack div {
width: 40px;
}
.navIcons {
transition: all 0.3s ease;
width:100%;
margin: 4px 0;
-webkit-filter: brightness(100%);
filter: brightness(100%);
cursor: pointer;
display: inline-block;
}
.navIcons:hover {
transform: scale(1.5);
-webkit-filter: brightness(70%);
filter: brightness(70%);
-webkit-transition: all 1s ease;
-moz-transition: all 1s ease;
-o-transition: all 1s ease;
-ms-transition: all 1s ease;
transition: all 1s ease;
}
</style>
HTMl:
<div class='navStack'>
<div>
<img class='navIcons' title='Definition' src="https://i.stack.imgur.com/fadxm.png" alt="" />
</div>
<div>
<img class='navIcons' title='Definition' src="https://i.stack.imgur.com/fadxm.png" alt="" />
</div>
</div>
When sizing your image a percentage of the parent div, the div stays the same size. So if you need to shrink the size of image, change your code as follow:
.navStack {
max-width: 10%;
}
.navIcons {
width: 100%;
/* max-width: 10%; */
/* max-height: 10%; */
}
The reset of your code stays the same.
Related
img {
width: 20px;
height: auto;
border-radius: 50%;
margin-bottom: 5px;
display: block;
transition: all 0.5s ease-in-out;
}
img:hover {
width: 200px;
height: auto;
border-radius: 0;
transition: all 0.5s ease-in-out;
}
<figure>
<img
src="https://i.stack.imgur.com/FuQYf.png"
alt="This is a picture"
/>
</figure>
I want to fix the center of this image in one place so that when the image grows, the expansion doesn't only happen in right direction, but both in the left and right directions, same for the upward and downward direction. (Here, it happens only in the downward direction.)
How do I do it? I tried setting margins to auto, but that centers the image the whole page, but I want it to be left aligned. Also, it doesn't seem to work for upward and downward direction.
Thanks!
You an achieve this by centering the image like this
img {
transform: translate(-50%, -50%);
}
img {
width: 20px;
height: auto;
border-radius: 50%;
margin-bottom: 5px;
display: block;
margin-top: 56px;
margin-left: 52px;
transform: translate(-50%, -50%);
transition: all 0.5s ease-in-out;
}
img:hover {
width: 200px;
height: auto;
border-radius: 0;
transition: all 0.5s ease-in-out;
}
<figure>
<img
src="https://i.stack.imgur.com/FuQYf.png"
alt="This is a picture"
/>
</figure>
I have a navigation menu that contains a burger icon made with 3 <span> that is inside another elements :
.navbar {
width: 100%;
color: #fff;
background-color: #df0024;
padding: 1% 0;
}
.tog {
display: flex;
cursor: pointer;
float: right;
width: 6%;
position: absolute;
top: 0;
right: 0;
bottom: 0;
align-items: center;
justify-content: center;
height: auto;
}
/*This is the div that contain the burger 3 layers*/
#nav-icon {
height: -webkit-fill-available;
height: -moz-fill-available;
height: -o-fill-available;
height: fill-available;
position: relative;
-webkit-transform: rotate(0deg);
-moz-transform: rotate(0deg);
-o-transform: rotate(0deg);
transform: rotate(0deg);
-webkit-transition: .5s ease-in-out;
-moz-transition: .5s ease-in-out;
-o-transition: .5s ease-in-out;
transition: .5s ease-in-out;
cursor: pointer;
}
/*/The style of each of the burger icon 3 layers*/
#nav-icon span {
display: block;
position: absolute;
height: 3.1vh;
width: 100%;
background: white;
border-radius: 9px;
opacity: 1;
left: 0;
-webkit-transform: rotate(0deg);
-moz-transform: rotate(0deg);
-o-transform: rotate(0deg);
transform: rotate(0deg);
-webkit-transition: .25s ease-in-out;
-moz-transition: .25s ease-in-out;
-o-transition: .25s ease-in-out;
transition: .25s ease-in-out;
}
#nav-icon span:nth-child(1) {
top: 0px;
}
#nav-icon span:nth-child(2) {
top: 12px;
}
#nav-icon span:nth-child(3) {
top: 24px;
}
<nav class="navbar">
<div class="logo">
<img src="" alt='Logo' />
</div>
<div id='tog' class="tog">
<label for="toggle" id='nav-icon'>
<div class='icon-container'>
<span></span>
<span></span>
<span></span>
</div>
</label>
</div>
</nav>
How to center the #nav-icon span inside the #nav-icon vertically ? All I want is centering the burger icon so I don't care of changing the other elements style that contain the burger icon.
I had to tweak a lot to make this work, but I used a nice vertical-centering trick I know involving top: 50%; plus transition: translateY(-50%);. If you apply those to a child div then it will be vertically centered within a sized parent (the parent should also have position relative or absolute).
I applied these styles to the .icon-container in your code.
.navbar{
width: 100%;
position: relative;
color: #fff;
background-color: #df0024;
padding: 1% 0;
}
.tog {
display: flex;
cursor: pointer;
float: right;
width: 6%;
position: absolute;
top: 0;
right: 0;
bottom: 0;
align-items: center;
justify-content: center;
height: auto;
}
/*This is the div that contain the burger 3 layers*/
#nav-icon{
position: absolute;
top:0;
bottom:0;
left:0;
right: 0;
-webkit-transition: .5s ease-in-out;
-moz-transition: .5s ease-in-out;
-o-transition: .5s ease-in-out;
transition: .5s ease-in-out;
cursor: pointer;
}
.icon-container {
padding: 0 5px;
box-sizing: border-box;
position: relative;
top: 50%;
-ms-transform: translateY(-50%); /* IE 9 */
-webkit-transform: translateY(-50%); /* Chrome, Safari, Opera */
transform: translateY(-50%);
}
#nav-icon span{
display: block;
width: 100%;
height: 5px;
margin-bottom: 3px;
background: white;
border-radius: 9px;
opacity: 1;
-webkit-transition: .25s ease-in-out;
-moz-transition: .25s ease-in-out;
-o-transition: .25s ease-in-out;
transition: .25s ease-in-out;
}
<nav class="navbar">
<div class="logo">
<img src="" alt='Logo'/>
</div>
<div id='tog' class="tog">
<label for="toggle" id='nav-icon'>
<div class='icon-container'>
<span></span>
<span></span>
<span></span>
</div>
</label>
</div>
</nav>
If you have nothing against flex, you may also drop the absolute positionning.
.navbar {
display: flex;
align-items: center;/* vertical-centering */
color: #fff;
background-color: #df0024;
padding: 1% 0;
/* DEMO PURPOSE ONLY to show vertical centering */
transition:0.25s;
height: 100px;
background-image:linear-gradient(to top, transparent 50%, rgba(255,255,255,0.15) 50%);
}
.navbar:hover {height:200px;}
/* end -- DEMO PURPOSE ONLY to show vertical centering */
nav a {
/* demo purpose , useless about centering */
margin: 0 0.5em;
color: white;
}
.tog {
cursor: pointer;
width: 1.5em;
margin-left: auto;/* goes all the way to the right side */
}
/*This is the div that contain the burger 3 layers*/
#nav-icon {
display: block;
transform: rotate(0deg);
transition: .5s ease-in-out;
cursor: pointer;
}
/*The style of each of the burger icon 3 layers*/
#nav-icon span {
display: block;
background: white;
margin: 0.25em 0;
border-radius: 9px;
opacity: 1;
height: 0.25em;
transform: rotate(0deg);
transition: .25s ease-in-out;
box-shadow: 1px 1px 1px;
}
<nav class="navbar">
<div class="logo">
<img src="" alt='Logo' />
</div>
another link ?
<div id='tog' class="tog">
<label for="toggle" id='nav-icon'>
<div class='icon-container'>
<span></span>
<span></span>
<span></span>
</div>
</label>
</div>
</nav>
I have the following html and CSS to have a box with an image where the title is centered. When hovering, the title is animated up and faded out while the text is faded in and animated from the bottom to the center.
This works well on PC but on touch devices, I have the problem that the user has to touch the image while scrolling to view the text. Touching the image once will immediately open the link.
Is there a way I can make it so that on mobile devices, the animation is executed when the user touches the image for the first time and the link is opened when touching for the second time? Touching outside the image should revert the animation.
I hope you can explain how I could achieve that (if it is possible). Or is there another, generally accepted way to deal with hover on mobile devices?
.content {
position: relative;
overflow: hidden;
display: flex;
display: -webkit-flex;
-webkit-align-items: center;
align-items: center;
justify-content: center;
}
.text_container {
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
}
.text_container div {
top: 50%;
transform: translateY(-50%);
}
.image_container {
width: 100%;
height: 100%;
}
.image {
object-fit: cover;
width: 100%;
height: 100%;
-webkit-transition: all 0.5s ease-in-out;
-moz-transition: all 0.5s ease-in-out;
transition: all 0.5s ease-in-out;
}
.content:hover .image {
transform: scale(1.1);
}
.text_container {
position: absolute;
display: flex;
display: -webkit-flex;
-webkit-align-items: center;
align-items: center;
width: 100%;
height: 100%;
}
.text_container>div {
position: absolute;
text-align: center;
width: 100%;
}
.text_container .title h2 {
opacity: 1;
margin: 0px;
padding: 0px;
-webkit-transition: all 0.5s ease-in-out;
-moz-transition: all 0.5s ease-in-out;
transition: all 0.5s ease-in-out;
-webkit-transform: translate3d(0,0,0);
transform: translate3d(0,0,0);
}
.content:hover .text_container .title h2 {
opacity: 0;
-webkit-transform: translate3d(0,-20px,0);
transform: translate3d(0,-20px,0);
}
.text_container .content div {
margin: 0px;
padding: 0px;
opacity: 0;
-webkit-transition: all 0.5s ease-in-out;
-moz-transition: all 0.5s ease-in-out;
transition: all 0.5s ease-in-out;
-webkit-transform: translate3d(0,20px,0);
transform: translate3d(0,20px,0);
}
.content:hover .text_container .content div {
opacity: 1;
-webkit-transform: translate3d(0,0,0);
transform: translate3d(0,0,0);
}
<div class="content">
<a href="www.google.com">
<div class="container">
<div class="image_container">
<img src="https://www.google.com/logos/2017/fischinger/bg_cta.jpg" />
</div>
<div class="text_container">
<div class="title">
<h2>My Title</h2>
</div>
<div class="content">
<div>
Some text.
</div>
</div>
</div>
</div>
</a>
</div>
I am trying to center an image on the page. I am using this:
#logo img {
max-width: 100%;
height: auto;
width: auto\9;
display: block;
margin: 55px auto;
-moz-transition: all 0.3s;
-webkit-transition: all 0.3s;
}
#logo img:hover {
-moz-transform: scale(1.1);
-webkit-transform: scale(1.1);
transform: scale(1.1);
margin-bottom: 100px;
}
<div id="logo">
<a href="http://sapsrp.x10.bz/">
<img src="images/logo.png" alt="SAPS Logo">
</a>
</div>
I want JUST the logo to be link, not the empty space next to it. What I mean, here
Adjust your CSS like this. You need to specify the width of the image
#logo img {
display: block;
margin-top: 55px auto;
-moz-transition: all 0.3s;
-webkit-transition: all 0.3s;
width: 100px;
height: auto;
}
#logo img:hover {
-moz-transform: scale(1.1);
-webkit-transform: scale(1.1);
transform: scale(1.1);
margin-bottom: 100px;
}
<div id="logo">
<a href="http://sapsrp.x10.bz/">
<img src="images/logo.png" alt="SAPS Logo">
</a>
</div>
If you want to maintain giving no size to the image you could remove the tag and alter the tag like this.
<img src="images/logo.png" alt="SAPS Logo" onclick='window.location="http://sapsrp.x10.bz/"'>
This is a slight hack as the user will not be able to right click to open the image in a new tab. Note, you will also need to give the img tag the cursor:pointer style
Change your css with these rules bellow
#logo {
text-align:center;
}
#logo img {
max-width: 100%;
height: auto;
width: auto;
margin: 55px auto;
-moz-transition: all 0.3s;
-webkit-transition: all 0.3s;
}
working fiddle https://jsfiddle.net/za5cgfLw/2/
#logo {
text-align: center;
}
#logo a {
display: inline-block;
margin: 55px auto;
}
#logo img {
max-width: 100%;
-moz-transition: all 0.3s;
-webkit-transition: all 0.3s;
}
#logo img:hover {
-moz-transform: scale(1.1);
-webkit-transform: scale(1.1);
transform: scale(1.1);
margin-bottom: 100px;
}
<div id="logo">
<a href="http://sapsrp.x10.bz/">
<img src="http://www.iconsdb.com/icons/preview/orange/stackoverflow-4-xxl.png" alt="SAPS Logo">
</a>
</div>
I'm currently trying to create a zoom effect on hover over one of my four images. The problem is most examples usually use tables or mask divs to apply some sort of effect.
Here's one example that implements what I would like this.
This is my code so far.
HTML
<div id="menu">
<img class ="blog" src="http://s18.postimg.org/il7hbk7i1/image.png" alt="">
<img class ="music" src="http://s18.postimg.org/4st2fxgqh/image.png" alt="">
<img class ="projects" src="http://s18.postimg.org/sxtrxn115/image.png" alt="">
<img class ="bio" src="http://s18.postimg.org/5xn4lb37d/image.png" alt="">
</div>
CSS
#menu {
max-width: 1200px;
text-align: center;
margin: auto;
}
#menu img {
width: 250px;
height: 375px;
padding: 0px 5px 0px 5px;
overflow: hidden;
}
.blog {
height: 375px;
-webkit-transition: all 1s ease;
-moz-transition: all 1s ease;
-o-transition: all 1s ease;
-ms-transition: all 1s ease;
transition: all 1s ease;
}
.blog:hover {
cursor: pointer;
height:475px;
width: 350px;
}
.music {
height: 375px;
}
.projects {
height: 375px;
}
.bio {
height: 375px;
}
What about using CSS3 transform property and use scale which ill give a zoom like effect, this can be done like so,
HTML
<div class="thumbnail">
<div class="image">
<img src="http://placehold.it/320x240" alt="Some awesome text"/>
</div>
</div>
CSS
.thumbnail {
width: 320px;
height: 240px;
}
.image {
width: 100%;
height: 100%;
}
.image img {
-webkit-transition: all 1s ease; /* Safari and Chrome */
-moz-transition: all 1s ease; /* Firefox */
-ms-transition: all 1s ease; /* IE 9 */
-o-transition: all 1s ease; /* Opera */
transition: all 1s ease;
}
.image:hover img {
-webkit-transform:scale(1.25); /* Safari and Chrome */
-moz-transform:scale(1.25); /* Firefox */
-ms-transform:scale(1.25); /* IE 9 */
-o-transform:scale(1.25); /* Opera */
transform:scale(1.25);
}
Here's a demo fiddle. I removed some of the element to make it simpler, you can always add overflow hidden to the .image to hide the overflow of the scaled image.
zoom property only works in IE
Here you go.
Demo
http://jsfiddle.net/27Syr/4/
HTML
<div id="menu">
<div class="fader">
<div class="text">
<p>Yay!</p>
</div>
<a href="http://stackoverflow.com/questions/15732643/jquery-masonry-and-css3/">
<img class ="blog" src="http://s18.postimg.org/il7hbk7i1/image.png" alt="">
</a>
</div>
<div class="fader">
<div class="text">
<p>Yay!</p>
</div>
<a href="http://stackoverflow.com/questions/15732643/jquery-masonry-and-css3/">
<img class ="blog" src="http://s18.postimg.org/4st2fxgqh/image.png" alt="">
</a>
</div>
<div class="fader">
<div class="text">
<p>Yay!</p>
</div>
<a href="http://stackoverflow.com/questions/15732643/jquery-masonry-and-css3/">
<img class ="projects" src="http://s18.postimg.org/sxtrxn115/image.png" alt="">
</a>
</div>
<div class="fader">
<div class="text">
<p>Yay!</p>
</div>
<a href="http://stackoverflow.com/questions/15732643/jquery-masonry-and-css3/">
<img class ="blog" src="http://s18.postimg.org/5xn4lb37d/image.png" alt="">
</a>
</div>
</div>
CSS
#menu {
text-align: center; }
.fader {
/* Giving equal sizes to each element */
width: 250px;
height: 375px;
/* Positioning elements in lines */
display: inline-block;
/* This is necessary for position:absolute to work as desired */
position: relative;
/* Preventing zoomed images to grow outside their elements */
overflow: hidden; }
.fader img {
/* Stretching the images to fill whole elements */
width: 100%;
height: 100%;
/* Preventing blank space below the image */
line-height: 0;
/* A one-second transition was to disturbing for me */
-webkit-transition: all 0.3s ease;
-moz-transition: all 0.3s ease;
-o-transition: all 0.3s ease;
-ms-transition: all 0.3s ease;
transition: all 0.3s ease; }
.fader img:hover {
/* Making images appear bigger and transparent on mouseover */
opacity: 0.5;
width: 120%;
height: 120%; }
.fader .text {
/* Placing text behind images */
z-index: -10;
/* Positioning text top-left conrner in the middle of elements */
position: absolute;
top: 50%;
left: 50%; }
.fader .text p {
/* Positioning text contents 50% left and top relative
to text container's top left corner */
margin-top: -50%;
margin-left: -50%; }
Suggestion
Instead of .fader { inline-block; } consider using some grid system. Based on your technology of preference, you can go Foundation, Susy, Masonry or their alternatives.
.aku {
transition: all .2s ease-in-out;
}
.aku:hover {
transform: scale(1.1);
}
I like using a background image. I find it easier and more flexible:
DEMO
CSS:
#menu {
max-width: 1200px;
text-align: center;
margin: auto;
}
.zoomimg {
display: inline-block;
width: 250px;
height: 375px;
padding: 0px 5px 0px 5px;
background-size: 100% 100%;
background-repeat: no-repeat;
background-position: center center;
transition: all .5s ease;
}
.zoomimg:hover {
cursor: pointer;
background-size: 150% 150%;
}
.blog {
background-image: url(http://s18.postimg.org/il7hbk7i1/image.png);
}
.music {
background-image: url(http://s18.postimg.org/4st2fxgqh/image.png);
}
.projects {
background-image: url(http://s18.postimg.org/sxtrxn115/image.png);
}
.bio {
background-image: url(http://s18.postimg.org/5xn4lb37d/image.png);
}
HTML:
<div id="menu">
<div class="blog zoomimg"></div>
<div class="music zoomimg"></div>
<div class="projects zoomimg"></div>
<div class="bio zoomimg"></div>
</div>
DEMO 2 with Overlay
Simply:
.grow { transition: all .2s ease-in-out; }
This will allow the element to assign an animation via css.
.grow:hover { transform: scale(1.1); }
This will make it grow!
.item:hover img
{
-moz-transform: scale(1.3);
-webkit-transform: scale(1.3);
transform: scale(1.3);
}
this way you can zoom any image with simple animation. If you need a complete tutorial here is a official tutorial: http://talkerscode.com/webtricks/image-zoom-in-on-hover-using-css3.php
SOLUTION 1: You can download zoom-master.
SOLUTION 2: Go to here .
SOLUTION 3: Your own codes
.hover-zoom {
-moz-transition:all 0.3s;
-webkit-transition:all 0.3s;
transition:all 0.3s
}
.hover-zoom:hover {
-moz-transform: scale(1.1);
-webkit-transform: scale(1.1);
transform: scale(1.5)
}
<img class="hover-zoom" src="https://i.stack.imgur.com/ewRqh.jpg"
width="100px"/>
<div class="item">
<img src="yamahdi1.jpg" alt="pepsi" width="50" height="58">
<img src="yamahdi.jpg" alt="pepsi" width="50" height="58">
<div class="item-overlay top"></div>
css:
.item img {
-moz-transition: all 0.3s;
-webkit-transition: all 0.3s;
transition: all 0.3s;
}
.item img:hover {
-moz-transform: scale(1.1);
-webkit-transform: scale(1.1);
transform: scale(1.1);
}
-webkit-transition: all 1s ease; /* Safari and Chrome */
-moz-transition: all 1s ease; /* Firefox */
-ms-transition: all 1s ease; /* IE 9 */
-o-transition: all 1s ease; /* Opera */
transition: all 1s ease;
just want to make a note on the above transitions only need
-webkit-transition: all 1s ease; /* Safari and Chrome */
transition: all 1s ease;
and -ms- certainly doenst work for IE 9 i dont know where you got that idea from.
.img-wrap:hover img {
transform: scale(0.8);
}
.img-wrap img {
display: block;
transition: all 0.3s ease 0s;
width: 100%;
}
<div class="img-wrap">
<img src="http://www.sampleimages/images.jpg"/> // Your image
</div>
This code is only for zoom-out effect.Set the div "img-wrap" according to your styles and insert the above style results zoom-out effect.For zoom-in effect you must increase the scale value(eg: for zoom-in,use
transform: scale(1.3);
#import url('https://fonts.googleapis.com/css?family=Muli:200,300,400,700&subset=latin-ext');
body{ font-family: 'Muli', sans-serif; color:white;}
#lists {
width: 350px;
height: 460px;
overflow: hidden;
background-color:#222222;
padding:0px;
float:left;
margin: 10px;
}
.listimg {
width: 100%;
height: 220px;
overflow: hidden;
float: left;
}
#lists .listimg img {
width: 350px;
height: 220px;
-moz-transition: all 0.3s;
-webkit-transition: all 0.3s;
transition: all 0.3s;
}
#lists:hover{cursor: pointer;}
#lists:hover > .listimg img {
-moz-transform: scale(1.3);
-webkit-transform: scale(1.3);
transform: scale(1.3);
-webkit-filter: blur(5px);
filter: blur(5px);
}
#lists h1{margin:20px; display:inline-block; margin-bottom:0px; }
#lists p{margin:20px;}
.listdetail{ text-align:right; font-weight:200; padding-top:6px;padding-bottom:6px;}
<div id="lists">
<div class="listimg">
<img src="https://lh3.googleusercontent.com/WeEw5I-wk2UO-y0u3Wsv8MxprCJjxTyTzvwdEc9pcdTsZVj_yK5thdtXNDKoZcUOHlegFhx7=w1920-h914-rw">
</div>
<div class="listtext">
<h1>Eyes Lorem Impsum Samet</h1>
<p>Impsum Samet Lorem</p>
</div>
<div class="listdetail">
<p>Click for More Details...</p>
</div>
</div>
<div id="lists">
<div class="listimg">
<img src="https://lh4.googleusercontent.com/fqK7aQ7auobK_NyXRYCsL9SOpVj6SoYqVlgbOENw6IqQvEWzym_3988798NlkGDzu0MWnR-7nxIhj7g=w1920-h870-rw">
</div>
<div class="listtext">
<h1>Two Frogs Lorem Impsum Samet</h1>
<p>Impsum Samet Lorem</p>
</div>
<div class="listdetail">
<p>More Details...</p>
</div>
</div>
<!DOCTYPE html>
<html>
<head>
<style>
.zoom {
overflow: hidden;
}
.zoom img {
transition: transform .5s ease;
}
.zoom:hover img {
transform: scale(1.5);
}
</style>
</head>
<body>
<h1>Image Zoom On Hover</h1>
<div class="zoom">
<img src="/image-path-url" alt="">
</div>
</body>
</html>
Add jQuery JavaScript library together with the jquery.zbox.css and jquery.zbox.js to your webpage.
<link rel="stylesheet" href="jquery.zbox.css">
<script src="jquery.min.js"></script>
<script src="jquery.zbox.min.js"></script>
Add a group of thumbnails with links pointing to the full sized images into the webpage.
<a class="zb" rel="group" href="1.png" title="Image 1">
<img src="thumb1.png">
</a>
<a class="zb" rel="group" href="2.png" title="Image 2">
<img src="thumb2.png">
</a>
<a class="zb" rel="group" href="3.png" title="Image 3">
<img src="thumb3.png">
</a>
Call the function on document ready. That's it.
In the view source do:
$(".zb").zbox();