Trying to add a scale effect on hover image - html

I'm trying to add a scale effect to the images that are available on the first part of my website: http://www.esportbooks.com/esports-news/
In fact, I already made this effect on the "News" section that is just below, if you hover over the images the effect is already in place and I use CSS to create it.
The only thing is that I don't know how to get the exact name of the CSS style to replicate this effect on the first 3 images, I tried several things but none of them work.
Could someone help me to find out?

Probably what are you looking for is the css property transform: scale()
you could check the example bellow:
*, *::before, *::after{
-moz-box-sizing: border-box;
box-sizing: border-box;
-webkit-transition: all 0.3s ease-in-out;
transition: all 0.3s ease-in-out;
}
html, body{
margin: 0px;
padding: 0px;
font-size: 18px;
font-weight: 300;
height: 100%;
color: #fff;
}
.container{
width: 1024px;
max-width: 100%;
margin: auto;
display: block;
text-align: center;
}
figure{
width: 400px;
height: 300px;
overflow: hidden;
position: relative;
display: inline-block;
vertical-align: top;
border: 5px solid #fff;
box-shadow: 0 0 5px #ddd;
margin: 1em;
}
figure img{
transition: all .3s ease-in-out;
transform: scale(1);
}
figure:hover img{
transform: scale(1.2);
}
<div class="container">
<figure>
<img src="http://placeimg.com/400/300/any" alt="Thumb" width="400" height="300" />
</figure>
<figure>
<img src="http://placeimg.com/400/300/nature" alt="Thumb" width="400" height="300" />
</figure>
</div>

Add this CSS code in your css file:
.fusion-image-wrapper {
transform: scale(1);
-webkit-transform: scale(1);
transition: all .5s;
-webkit-transition: all .5s;
}
.fusion-post-wrapper:hover .fusion-image-wrapper {
transform: scale(1.7);
-webkit-transform: scale(1.7);
}

Related

How to fix the center of an image in one place for an animation?

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>

Set Div Width To Img Content

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.

Centering an image on page, the entire div is becoming a link?

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>

Can any one help hover an image of an icon vertically and horizontally within a div with a border radius

I am trying to place an image at the center of each of the following four divs.I have tried placing the image as a background and it covers it but due to the border radius it doesn't look quite right. I have included a fiddle for reference.
HTML:
<div id="gold" class="divSquare">1</div>
<div id="lblue" class="divSquare">2</div>
<div style='clear:both'></div>
<div id="redb" class="divSquare">3</div>
<div id="dblue" class="divSquare">4</div>
CSS:
#gold{
background-color:#F3B500;
border-radius: 100px 100px 5px 100px;
transition: all .2s ease-in-out; }
#gold:hover{
opacity: 0.8;
transform: scale(1.2);
border:none;
margin:8px;
}
#lblue{
background-color:#0E43C6;
transition: all .2s ease-in-out;
border-radius: 100px 100px 100px 5px; }
#lblue:hover{
opacity: 0.8;
transform: scale(1.2);
margin:8px;}
#redb{
background-color:#7E0202;
transition: all .2s ease-in-out;
border-radius: 100px 5px 100px 100px;
}
#redb:hover{
opacity: 0.5;
transform: scale(1.2);
margin:8px;}
#dblue{
background-color:#041871;
transition: all .2s ease-in-out;
border-radius: 5px 100px 100px 100px;
}
#dblue:hover{
opacity: 0.5;
transform: scale(1.2);
margin:8px;}
.divSquare{
width:100px; height:100px; margin:2px;float:left;
text-align: center;
vertical-align: middle;
line-height: 150px;}
http://jsfiddle.net/gerryboy/osaqnzoL/
You could center content in your divs using flexbox (if it's not a problem for your compatibility requirements):
.divSquare {
display: flex;
justify-content: center;
align-items: center;
}
See Fiddle
As per my understanding you want place the image using css property background-image on div and OnHover of div you want to increase the size of the div and the image also.
Please let Know if my understanding is right.
I'd be using a background image unless there's an absolute requirement tha the image be content.
* {
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
box-sizing: border-box;
}
body {
padding: 3em;
}
#gold {
background-color: #F3B500;
background-image: url(http://lorempixel.com/output/abstract-q-c-25-25-2.jpg);
background-repeat: no-repeat;
background-position: center center;
border-radius: 100px 100px 5px 100px;
transition: all .2s ease-in-out;
transform-origin: bottom right;
}
#gold:hover {
opacity: 0.8;
transform: scale(1.2);
border: none;
}
#lblue {
background-color: #0E43C6;
transition: all .2s ease-in-out;
border-radius: 100px 100px 100px 5px;
transform-origin: bottom left;
}
#lblue:hover {
opacity: 0.8;
transform: scale(1.2);
}
#redb {
background-color: #7E0202;
transition: all .2s ease-in-out;
border-radius: 100px 5px 100px 100px;
transform-origin: top right;
}
#redb:hover {
opacity: 0.5;
transform: scale(1.2);
}
#dblue {
background-color: #041871;
transition: all .2s ease-in-out;
border-radius: 5px 100px 100px 100px;
transform-origin: top left;
}
#dblue:hover {
opacity: 0.5;
transform: scale(1.2);
}
.divSquare {
width: 100px;
height: 100px;
margin: 2px;
float: left;
text-align: center;
vertical-align: middle;
line-height: 100px;
color: white;
}
<div id="gold" class="divSquare">1</div>
<div id="lblue" class="divSquare">2</div>
<div style='clear:both'></div>
<div id="redb" class="divSquare">3</div>
<div id="dblue" class="divSquare">4</div>
Another solution is the position / margin top properties at 50% and an opposite transform: translateY of 50% for the vertical alignment.
position: relative;
top: 50%;
transform: tranlateY(-50%);
Here is a demo with some CSS enhancements.
This one is with images as background covering all the shapes. Needs tweaking, but can be achieved. don't forget to use the:
.divSquare{
overflow: hidden;
}
to mask out the bleeding of the images.

Image hover effect doesn't work over text

I have an image I want to display as a link. I have a hover effect when the mouse is over the image, but I also want to overlay a text label onto the image. The problem is, when the mouse is over the text, the image effect stops working.
My code is below. Can anyone suggest how I can fix this?
<html>
<style>
* {
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
-ms-box-sizing: border-box;
box-sizing: border-box;
}
.pic {
border: 5px solid #FF0000;
float: left;
width: 475px;
height: 375px;
margin: 20px;
overflow: hidden;
position: relative;
-webkit-box-shadow: 5px 5px 5px #C0C0C0;
box-shadow: 5px 5px 5px #C0C0C0;
}
.grow img {
width: 475px;
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;
}
.grow img:hover {
width: 570px;
height: 450px;
}
.label {
top: 150px;
position:absolute;
text-align:center;
font-size:500%;
color: FF0000;
width: 100%;
}
</style>
<a href="MyLink.html">
<div class="grow pic">
<img src="MyImage.jpg" alt="TITLE">
<div class="label">TITLE</div>
</div>
</a>
You could try disabling pointer-events:
.label { pointer-events:none; }
Your hover is just on your image, apply the hover to the div.
example:
.grow:hover img {
//styles
}