How to make this text grow when an image is hovered over? - html

I want .thumb_text to grow when li.thumb_list <img> is hovered over. Currently, I can only get it to scale when I hover over the text, but not the <img>.
Also, for some reason the text is boldening no matter what weight or font family I give it.
li.thumb_list img {
-webkit-transform: scale(1.3);
transform: scale(1.3);
-webkit-transition: .3s ease-in-out;
transition: .3s ease-in-out;
}
li.thumb_list:hover img {
-webkit-transform: scale(1);
transform: scale(1);
}
h1.thumb_text {
-webkit-transform: scale(1);
transform: scale(1);
-webkit-transition: .3s ease-in-out;
transition: .3s ease-in-out;
}
h1.thumb_text:hover {
-webkit-transform: scale(1.1);
transform: scale(1.1);
}
.photo_thumbnails {
display: inline-block;
width: 1300px;
height: 235px;
overflow: hidden;
position: relative;
}
.thumbnail_container {
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
transform: -webkit-translate(-50%, -50%);
transform: -moz-translate(-50%, -50%);
transform: -ms-translate(-50%, -50%);
}
li.thumb_list {
display: inline-block;
overflow: hidden;
height: auto;
margin: auto;
text-align: center;
position: relative;
}
h1.thumb_text {
position: absolute;
margin: auto;
top: 0;
left: 0px;
right: 0px;
bottom: 0;
color: #FFF;
height: 50px;
width: 200px;
z-index: 999;
vertical-align: middle;
text-align: center;
font-family: 'anonymous pro', monospace;
font-size: 20px;
font-weight: 100;
}
<div class="thumbnail_container">
<div class="photo_thumbnails">
<ul>
<li class="thumb_list">
<a href="http://scottnorris.co.uk/photos/uk.html"><img src="Photos/Thumbnails/UK.jpg" width="300" height="225">
<h1 class="thumb_text">uk landscapes</h1>
</a>
</li>
<li class="thumb_list">
<a href="http://scottnorris.co.uk/photos/asia.html"><img src="Photos/Thumbnails/Asia.jpg" width="300" height="225">
<h1 class="thumb_text">asian landscapes</h1>
</a>
</li>
<li class="thumb_list">
<a href="http://scottnorris.co.uk/photos/forgotten.html"><img src="Photos/Thumbnails/Lost.jpg" width="300" height="225">
<h1 class="thumb_text">lost & forgotten</h1>
</a>
</li>
<li class="thumb_list">
<a href="http://scottnorris.co.uk/photos/in-nature.html"><img src="Photos/Thumbnails/In_Nature.jpg" width="300" height="225">
<h1 class="thumb_text">in nature</h1>
</a>
<li>
</ul>
</div>
</div>

If you only want the text to increase while hovering img you can use the CSS sibling selector like this:
.thumb_list img:hover + .thump_text{
font-size:50px;
}
Note that if you Hover the text with only this CSS it will decrease again, given that you've only chosen the Hover effect for the img.
To get around this you have (at least) two choices: set the Hover effect to the container instead (no need for sibling selector then) or add pointer-events: none to the .thump_text
With regard to your font being only bold, I guess it could be because you only have one font-weight available with your custom font. Usually you have to provide the browser with different files for each weight of font. On the other hand though, the browser usually tries to create its own weight, when either of the extremes is applied (100 or bold/700). This is just a guess though, but could be a possible reason.

Related

How to put text on top of image?

I have some HTML and CSS setup for a simple image gallery.
I've been trying to add white text on top of each of the images in the center.
Link to HTML + CSS:
https://jsfiddle.net/babis95/zdhne95u/
.section-images
{
padding: 0;
}
.images-showcase
{
list-style: none;
width: 100%;
}
.images-showcase li
{
display: block;
float: left;
width: 25%;
}
.destination-photo
{
width: 100%;
margin: 0;
overflow: hidden;
background-color: #000;
}
.destination-photo img
{
opacity: 0.7;
width: 100%;
height: auto;
transform: scale(1.15);
transition: transform 0.5s, opacity 0.5s;
}
.destination-photo img:hover
{
opacity: 1;
transform: scale(1.03);
}
.section-images p
{
color: white;
margin: 0;
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
}
<section class='section-images'>
<ul class='images-showcase'>
<li>
<figure class='destination-photo'>
<img src='https://image.shutterstock.com/image-photo/blue-suitcase-sun-glasses-hat-600w-1094945555.jpg' alt='Image 1'>
<p>IMAGE TEXT 1</p>
</figure>
</li>
<li>
<figure class='destination-photo'>
<img src='https://image.shutterstock.com/image-photo/overhead-view-travelers-accessories-essential-600w-425996818.jpg' alt='Image 2'>
</figure>
</li>
<li>
<figure class='destination-photo'>
<img src='https://image.shutterstock.com/image-photo/woman-traveler-suitcase-on-color-600w-578891674.jpg' alt='Image 3'>
</figure>
</li>
</ul>
</section>
I researched different ways but none seem to work with they way i set up my code:
.section-images p
{
color: white;
margin: 0;
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
}
all this does is, adds a the text in the middle of the whole container, and moves images off of the alignment
This code seem to work on single image in a div, but not when multiple images are used.
You just need position: relative; on your .destination-photo
Your Text is placed on an absolute position. Since you don't have a relative position, the images are placed absolutely to the document. Adding position: relative to the image would give the p tags a position to start with.

make images expand on hover from center and make image still stay in box

I am trying to make my images act like this: http://www.kas.tw/ (hover over images beneath the image carousel) but my images expand from the side and I can't figure out how to make the image still stay in its box, here is the code.
CSS
#image3{
top: 130%;
left: 20%;
display: none;
}
#cover1{
width: 5%;
height: 100%;
left: 47%;
background-color: green;
z-index: 2;
top: 94%;
position: absolute;
}
.zoom {
padding: 50px;
transition: transform .2s; /* Animation */
margin: 0 auto;
}
.zoom:hover {
transform: scale(1.5); /* (150% zoom - Note: if the zoom is too large,
it will go outside of the viewport) */
}
HTML
<DIV class='zoom' id='image1'><IMG width='50%' height='90%' src="slime3.JPG"></DIV>
<DIV id='image2'><IMG width='50%' height='90%' src="slime4.JPG"></DIV>
<DIV id='image3'><IMG width='50%' height='90%' src="slime5.JPG"></DIV>
<DIV id='image4'><IMG width='50%' height='90%' src="slime6.JPG"></DIV>
<DIV id='image5'><IMG width='50%' height='90%' src="slime7.JPG"></DIV>
<DIV id='image6'><IMG width='50%' height='90%' src="slime8.JPG"></DIV>
<DIV id='cover1'><DIV>
<DIV id='cover2'><DIV>
<DIV id='cover3'><DIV>
<DIV id='cover4'><DIV>
<DIV id='cover5'><DIV>
You can make images stay in the box without expanding its container size.
This can be done purely on CSS by using max-width,max-height to set a specific box size and to use overflow: hidden to hide the excess image when it expands past the width and height.
transform: scale(2,2) allows the image to zoom from the center.
Try this:
#holder {
max-width: 200px;
max-height: 200px;
overflow: hidden;
}
#holder img {
width: 100%;
-webkit-transition: all 0.8s ease;
-moz-transition: all 0.8s ease;
transition: all 0.8s ease;
}
#holder img:hover {
transform: scale(2,2);
}
<div id="holder">
<img src="https://picsum.photos/200/200">
</div>
You could try this
<div class="item">
<img>..</img>
</div>
and for css
.item:hover img {
-moz-transform: scale(1.1);
-webkit-transform: scale(1.1);
transform: scale(1.1);
}

rotateY or rotateX just make my picture smaller when they rotate it

I have a product div and whenever I hover over it, it rotated and shows the other side, it works and all but the thing is it becomes smaller, here's an idea of what it looks like here.
.product {
transform: scale(1.5);
transition: transform 1s cubic-bezier(.1, -.60, .50, 1.2);
perspective: 700px;
transform-style: preserve-3d;
}
.inner img {
height: 65px;
width: 65px;
}
.product:hover {
transform: rotateY(-180deg);
}
.product:hover .side-b {
transform: rotateY(180deg);
display: block;
}
.product:hover .side-a {
visibility: hidden;
}
.product-desc {
color: #fff;
position: absolute;
top: 0;
right: 0;
bottom: 0;
left: 0;
padding-left: 20px;
padding-right: 20px;
display: flex;
/* For centering text inside .photo-overlay */
flex-direction: column;
justify-content: center;
align-items: center;
display: none;
line-height: 0;
}
<li>
<div class="product">
<div style="height: 7px;visibility: hidden;"></div>
<div class="inner">
<img class="side-a" src="../images/test.jpg" alt="International Space Station">
<div class="product-desc side-b">
<h3>hi</h3>
buy
</div>
</div>
</div>
</li>
The resizing is because of your first rule transform: scale(1.5);. It tells the browser to initially resize the .product element to 50% more than its original size. But than on hover, you overwrite your transform- rule by only a rotation statement. Either delete this first rule or also use it in your :hover definition:
.product:hover {
transform: scale(1.5) rotateY(-180deg);
}
The transform: scale(1.5); created the problem!
Thanks to #Mohd Asim Suhail for pointing it out!
transform: scale(1.5); is creating problem for you, – Mohd Asim Suhail 3 mins ago

Hoover zoom effect with multiple images and keep image dimension

I am trying to make a hover zoom effect with multiple images:
images are centered on the page
keep dimensions while zooming in
image width is set inline at img tag
Here is what I tried so far:
.img-zoom {
display: inline-block;
width: 100%;
height: 100%;
position: relative;
overflow: hidden;
}
.img-zoom img {
-webkit-transform: scale(1.04);
-ms-transform: scale(1.04);
transform: scale(1.04);
-webkit-transition: 0.4s ease;
transition: 0.4s ease;
margin: 0px 20px;
}
.img-zoom img:hover {
-webkit-transform: scale(1.21);
-ms-transform: scale(1.21);
transform: scale(1.21);
}
<div style="text-align: center;padding: 5px;">
<div class="img-zoom">
<img src="http://lorempixel.com/600/210" width="300" />
<img src="http://lorempixel.com/600/210" width="300"/>
</div>
</div>
...but the images are extending on mouse hover.
It sounds like you want the images to zoom in without their width/height changing. I've modified your HTML a bit and placed the inline width parameter on the .img-zoom element. I think this accomplishes what you need.
.img-zoom {
display: inline-block;
position: relative;
overflow: hidden;
}
.img-zoom img {
display: block;
width: 100%;
transition: 0.4s ease;
transform-origin: 50% 50%; /* center zoom */
}
.img-zoom img:hover {
transform: scale(1.21);
}
<div style="padding: 5px; text-align: center;">
<div class="img-zoom" style="width: 300px;">
<img src="http://lorempixel.com/600/210" />
</div>
<div class="img-zoom" style="width: 300px;">
<img src="http://lorempixel.com/600/210"/>
</div>
</div>

How do I make just an image clickable and not the entire div? [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 7 years ago.
Improve this question
How do I go about making just an image clickable and not the entire div that the clickable image is inside of? In this case, the first image, .home, an anchor, and the div that contains it, .nav, is clickable. There's a second image that doesn't have an anchor, so it's ok. How do I make just the first image inside the anchor clickable but not the div that contains them?
img.home {
display: block;
margin-left: auto;
margin-right: auto;
margin-top: 25px;
-webkit-transition-duration: 0.8s;
-moz-transition-duration: 0.8s;
transform-duration: 0.8s;
}
img.home:hover {
-webkit-transform: rotate(360deg);
-moz-transform: rotate(360deg);
transform: rotate(360deg);
}
img.catfalogo {
position: absolute;
display: block;
margin: 0 auto;
top: 155px;
left: 50%;
z-index: 1;
text-align: center;
-webkit-transform: translate(-50%, -50%);
transform: translate(-50%, -50%);
}
.nav {
position: fixed;
height: 212px;
width: 100%;
background: #C9D4E7;
z-index: 2;
top: 0px;
}
<div class="nav">
<p>Click to the right or left of the img.home and it will be clickable. I don't want that. I only want img.home (spinning shield) to be clickable.</p>
<a href="informationindex.html">
<img class="home" src="http://i.ebayimg.com/images/a/T2eC16ZHJHQE9nzEy9TZBQgKMjrbTw~~/s-l64.jpg" alt="home" width="67px" height="67px">
</a>
<img class="catfalogo" src="https://vgboxart.com/resources/logo/2250_captain-america-the-first-avenger-prev.png" alt="catfa logo" height="90px">
</div>
img In this image, the darker area is what is currently clickable. I only want the circular image (Capt. America's shield) to be clickable. Not the entire space around it.
Thank you!
The first image is clickable. The div is not clickable. Assign pointer-events: none to any elements' style (inline, external, etc.) and it won't be clickable. The default is pointer-events: auto;
img.home {
display: block;
margin-left: auto;
margin-right: auto;
margin-top: 25px;
-webkit-transition-duration: 0.8s;
-moz-transition-duration: 0.8s;
transition-duration: 0.8s;
pointer-events: auto;
}
img.home:hover {
-webkit-transform: rotate(360deg);
-moz-transform: rotate(360deg);
transform: rotate(360deg);
}
img.catfalogo {
position: absolute;
display: block;
margin: 0 auto;
top: 155px;
left: 50%;
z-index: 1;
text-align: center;
-webkit-transform: translate(-50%, -50%);
transform: translate(-50%, -50%);
}
.nav {
position: fixed;
height: 212px;
width: 100%;
background: #C9D4E7;
z-index: 2;
top: 0px;
pointer-events: none;
}
<div class="nav">
<a href="informationindex.html">
<img class="home" src="http://i.ebayimg.com/images/a/T2eC16ZHJHQE9nzEy9TZBQgKMjrbTw~~/s-l64.jpg" alt="home" width="67px" height="67px">
</a>
<img class="catfalogo" src="https://vgboxart.com/resources/logo/2250_captain-america-the-first-avenger-prev.png" alt="catfa logo" height="90px">
</div>
EDIT: Although the original demo was adequate to convey instructions to the OP, I have edited it because it seems that a certain member is going at great lengths to bury this question.