How to add a image zoom effect with a text overlay using css - html

I am trying to get an effect using css which I keep getting 90% right but each time I try something different, it results in another problem elsewhere.
What I am trying to do:
Have the image zoom on mouseover
Have the text remain in place and not zoom
Problem:
The hover works fine EXCEPT when the mouse goes over the text-overlay (because the effect is on img:hover. I effectively want the text-overlay to be visible to the eyes BUT transparent to the mouse-over
Here is my fiddle: https://jsfiddle.net/knrrrfxo/
I have tried making the image a background image but that creates a whole other list of issues with responsive sizing which also wont work.
Code:
<style>
.tile-wrapper {
margin:0;
padding:0;
overflow: hidden;
position: relative;
}
.new-arrivals-link {
line-height: 0;
}
.new-arrivals-link 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;
}
.new-arrivals-link img:hover {
-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);
}
.new-arrivals-link img:hover {
opacity: 0.8;
}
.tile-wrapper .text-overlay {
position: absolute;
width: 50%;
height: 50%;
overflow: auto;
margin: auto;
top: 0;
left: 0;
bottom: 0;
right: 0;
text-align: center;
}
.tile-wrapper .text-overlay h2 {
color: white;
font-size: 60px;
line-height: 74px;
margin: 0 0 10px;
}
.tile-wrapper .text-overlay p {
color: white;
font-size: 28px;
}
</style>
<div class="tile-wrapper">
<a href="#" itemprop="url" class="new-arrivals-link">
<img src="https://cdn.shopify.com/s/files/1/1307/5753/files/new-arrivals-tab.jpg?6713767595666642894" width="100%" alt="New Arrivals">
<div class="text-overlay">
<h2>NEW<br>ARRIVALS</h2>
<p>Shop Now</p>
</div>
</a>
</div>

You can set pointer-events: none; on the .text-overlay div.

All you need is change a single selector to apply to hover of the parent instead of the image element, like so (the changed line is indicated by a comment):
.tile-wrapper {
margin:0;
padding:0;
overflow: hidden;
position: relative;
}
.new-arrivals-link {
line-height: 0;
}
.new-arrivals-link 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;
}
.new-arrivals-link:hover img { /* this line has been changed */
-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);
}
.new-arrivals-link img:hover {
opacity: 0.8;
}
.tile-wrapper .text-overlay {
position: absolute;
width: 50%;
height: 50%;
overflow: auto;
margin: auto;
top: 0;
left: 0;
bottom: 0;
right: 0;
text-align: center;
}
.tile-wrapper .text-overlay h2 {
color: white;
font-size: 60px;
line-height: 74px;
margin: 0 0 10px;
}
.tile-wrapper .text-overlay p {
color: white;
font-size: 28px;
}
<div class="tile-wrapper">
<a href="#" itemprop="url" class="new-arrivals-link">
<img src="https://cdn.shopify.com/s/files/1/1307/5753/files/new-arrivals-tab.jpg?6713767595666642894" width="100%" alt="New Arrivals">
<div class="text-overlay">
<h2>NEW<br>ARRIVALS</h2>
<p>Shop Now</p>
</div>
</a>
</div>
This works because it applies when the parent element of both the image and the text box is hovered over, which is also true if you hover over any of it's child elements.

Related

How can I make the child element change when hover is applied on the parent?

How can I make the child element change when hover is applied on the parent ?
I want to make the icon inside the box scale whenever I hover the box with the image. I would like to keep these same effects but when I hover the box everything is affected.
Thank you!
.box {
display: inline-block !important;
position: relative !important;
overflow: hidden;
background-color: rgba(50, 58, 70, .3);
}
.box-overlay {
position: absolute;
transition: background 0.2s ease, padding 0.8s linear;
background-color: rgba(50, 58, 70, .6);
width: 100%;
height: 100%;
}
.box-overlay > span {
display: none;
}
.box-overlay:hover > span {
display: inline;
}
.box a:hover .box-overlay {
display: inline;
text-align: center;
position: absolute;
transition: background 0.2s ease, padding 0.8s linear;
background-color: rgba(50, 58, 70, .3);
color: #fff;
width: 100%;
height: 100%;
}
.box-overlay span {
transition: all 0.3s ease-in-out;
}
.box-overlay span {
position: relative;
top: 38%;
-webkit-transform: translateY(-50%);
-ms-transform: translateY(-50%);
transform: translateY(-50%);
}
.go img{
-webkit-transition: all .3s ease; /* Safari and Chrome */
-moz-transition: all .3s ease; /* Firefox */
-ms-transition: all .3s ease; /* IE 9 */
-o-transition: all .3s ease; /* Opera */
transition: all .3s ease;
}
.go img:hover {
-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);
}
<div class="box">
<a href="#">
<div class="box-overlay">
<span class="go">
<img src="img/go.svg" width="50px" height="50px">
</span>
</div>
<img src="img/aa-family-car.jpg" alt="" height="300" width="300" class="responsive">
</a>
</div>
How can I make the child element change when hover is applied on the parent ? I want to make the icon inside the box scale whenever I hover the box with the image.
The parent of the "icon" is the span so this
.go img:hover {
-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);
}
should be this
.go: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);
}
If you mean that the icon should scale when you hover over the whole thing then
.box:hover .go 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);
}
I've simplified the final version code a little in this JSFiddle Demo

scrollbar css for firefox in angularjs project

My requirement is : I have angular project but custom scrollbar not appear in firefox, I added library simplebar css and simplebar js from github, could not fix it? Does any one know how to do this?
My code is :
.simplebar {
overflow: scroll;
/*height: 100%;*/
height: -moz-calc(100% - 75px);
height: -webkit-calc(100% - 75px);
height: calc(100% - 75px);
position: absolute;
}
.simplebar-scrollbar,
[data-simplebar-direction] {
position: relative;
overflow: hidden;
-webkit-overflow-scrolling: touch;
/* Trigger native scrolling for mobile, if not supported, plugin is used. */
}
.simplebar-scrollbar .simplebar-scroll-content,
[data-simplebar-direction] .simplebar-scroll-content {
overflow-y: scroll;
overflow-x: auto;
position: absolute;
left: 0;
right: 0;
top: 0;
bottom: 0;
-ms-overflow-style: none;
/* hide browser scrollbar on IE10+ */
}
/* hide browser scrollbar on Webkit (Safari & Chrome) */
.simplebar-scroll-content::-webkit-scrollbar {
display: none;
}
[data-simplebar-direction="horizontal"] .simplebar-scroll-content,
.simplebar.horizontal .simplebar-scroll-content {
overflow-x: scroll;
overflow-y: auto;
}
.simplebar-scrollbar-track {
z-index: 99;
position: absolute;
top: 0;
right: 0;
bottom: 0;
width: 11px;
}
.simplebar-strack .simplebar-scrollbar {
position: absolute;
right: 2px;
-webkit-border-radius: 7px;
-moz-border-radius: 7px;
border-radius: 7px;
min-height: 10px;
width: 7px;
opacity: 0;
-webkit-transition: opacity 0.2s linear;
-moz-transition: opacity 0.2s linear;
-o-transition: opacity 0.2s linear;
-ms-transition: opacity 0.2s linear;
transition: opacity 0.2s linear;
background: #6c6e71;
-webkit-background-clip: padding-box;
-moz-background-clip: padding;
}
.simplebar-track:hover .simplebar-scrollbar {
/* When hovered, remove all transitions from drag handle */
opacity: 0.7;
-webkit-transition: opacity 0 linear;
-moz-transition: opacity 0 linear;
-o-transition: opacity 0 linear;
-ms-transition: opacity 0 linear;
transition: opacity 0 linear;
}
.simplebar-track .simplebar-scrollbar.visible {
opacity: 0.7;
}
[data-simplebar-direction="horizontal"] .simplebar-track,
.simplebar.horizontal .simplebar-track {
top: auto;
left: 0;
width: auto;
height: 11px;
}
[data-simplebar-direction="horizontal"] .simplebar-track .simplebar-scrollbar,
.simplebar.horizontal .simplebar-track .simplebar-scrollbar {
right: auto;
top: 2px;
height: 7px;
min-height: 0;
min-width: 10px;
width: auto;
}
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js">
</script>
<!--<script>window.jQuery || document.write('<script src="vendor/jquery - 1.10.2.min.js "><\/script>')</script>-->
<script src="simplebar.js"></script>
<script src="simpebar.min.js"></script>
<div class="simplebar">
<!--Start SCROLL BAR, Div Added/Edited by VIKAS GAYAKWAD -->
<ul class="media-list">
<contact-card data-client="client" ng-repeat="client in clientList"></contact-card>
</ul>
</div>
<!--End SCROLL BAR--->

Pure CSS3 Responsive Lightbox Appears Half-Off Screen

Created a LightBox effect using pure CSS and HTML, no JS. The image appears, but on the right side of the screen, halfway cut off, and partially underneath my Nav bar. Half of the screen is shaded behind the image.
It appears like it would work, aside from it being off-center and behind the navigation. From the code at hand, is there anything that appears it could be doing this? I'd be happy to post more code if necessary. Thank you!
/*Eliminates padding, centers the thumbnail */
body,
html {
padding: 0;
margin: 0;
text-align: center;
float: left;
}
/* Styles the thumbnail */
a.lightbox img {
height: 150px;
border: 3px solid white;
box-shadow: 0px 0px 8px rgba(0, 0, 0, 0.3);
margin: 94px 20px 20px 20px;
}
/* Styles the lightbox, removes it from sight and adds the fade-in transition */
.lightbox-target {
position: fixed;
top: -100%;
width: 100%;
background: rgba(0, 0, 0, 0.7);
width: 100%;
opacity: 0;
-webkit-transition: opacity .5s ease-in-out;
-moz-transition: opacity .5s ease-in-out;
-o-transition: opacity .5s ease-in-out;
transition: opacity .5s ease-in-out;
overflow: hidden;
clear: both;
}
/* Styles the lightbox image, centers it vertically and horizontally, adds the zoom-in transition and makes it responsive using a combination of margin and absolute positioning */
.lightbox-target img {
margin: auto;
position: absolute;
top: 0;
left: 0;
right: 0;
bottom: 0;
max-height: 0%;
max-width: 0%;
border: 3px solid white;
box-shadow: 0px 0px 8px rgba(0, 0, 0, 0.3);
box-sizing: border-box;
-webkit-transition: .5s ease-in-out;
-moz-transition: .5s ease-in-out;
-o-transition: .5s ease-in-out;
transition: .5s ease-in-out;
}
/* Styles the close link, adds the slide down transition */
a.lightbox-close {
display: block;
width: 50px;
height: 50px;
box-sizing: border-box;
background: white;
color: black;
text-decoration: none;
position: absolute;
top: -80px;
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;
}
/* Provides part of the "X" to eliminate an image from the close link */
a.lightbox-close:before {
content: "";
display: block;
height: 30px;
width: 1px;
background: black;
position: absolute;
left: 26px;
top: 10px;
-webkit-transform: rotate(45deg);
-moz-transform: rotate(45deg);
-o-transform: rotate(45deg);
transform: rotate(45deg);
}
/* Provides part of the "X" to eliminate an image from the close link */
a.lightbox-close:after {
content: "";
display: block;
height: 30px;
width: 1px;
background: black;
position: absolute;
left: 26px;
top: 10px;
-webkit-transform: rotate(-45deg);
-moz-transform: rotate(-45deg);
-o-transform: rotate(-45deg);
transform: rotate(-45deg);
}
/* Uses the :target pseudo-class to perform the animations upon clicking the .lightbox-target anchor */
.lightbox-target:target {
opacity: 1;
top: 0;
bottom: 0;
}
.lightbox-target:target img {
max-height: 100%;
max-width: 100%;
}
.lightbox-target:target a.lightbox-close {
top: 0px;
}
<div id="gravel-button">
<a class="lightbox" href="#gravel-1">
<h7>Photo & Info</h7>
</a>
</div>
<div class="lightbox-target" id="gravel-1">
<img src="http://www.sbsg.com/wp-content/uploads/2010/02/58minus.jpg">
<a class="lightbox-close"></a>
</div>

Vertical aligning text

I'm trying to vertically align some text in a div whilst the text is under an image.
I'm not very good at explaining things but this is the code I have so far: https://jsfiddle.net/c1249bd8/
HTML:
<div class="childContainer">
<a href="#" class="childLink">
<img src="http://placekitten.com/g/500/500" alt="Test" class="childImg"/>
<h1 class="childName">Testing</h1>
</a>
</div>
CSS:
.childContainer {
/* Height and width */
height: 10rem;
width: 10rem;
/* Hide overflow */
overflow: hidden;
/* Allows z-index */
position: relative;
/* Circle */
border-radius: 50%;
}
.childLink {
/* No default link styling */
color: #000;
text-decoration: none;
/* All Bubble is link */
height: 100%;
width: 100%;
/* Circle */
border-radius: 50%;
}
.childImg {
/* Full Bubble */
height: 100%;
width: 100%;
/* On top of text */
z-index: 1;
position: absolute;
/* Fade in/out stuff */
opacity: 1;
transition: opacity .30s ease-in-out;
-moz-transition: opacity .30s ease-in-out;
-webkit-transition: opacity .30s ease-in-out;
}
.childNameWrapper {
vertical-align: middle;
display: table-cell;
}
#import url('http://fonts.googleapis.com/css?family=Roboto:400,300|Luckiest+Guy');
.childName {
/* Behind Image */
position: absolute;
z-index: 0;
/* In Center */
text-align: center;
/* Nice handwriting font */
font-family: 'Luckiest Guy', cursive;
}
.childImg:hover {
/* Fade on hover */
opacity: 0;
transition: opacity .30s ease-in-out;
-moz-transition: opacity .30s ease-in-out;
-webkit-transition: opacity .30s ease-in-out;
}
Thanks,
Oscar.
Use display flex. It is quite easy and simple to use.
Check the FIDDLE.
.childLink {
display:flex;
align-items : center;
/* No default link styling */
color: #000;
position:relative;
text-decoration: none;
/* All Bubble is link */
height: 100%;
width: 100%;
/* Circle */
border-radius: 50%;
// vertical-align:middle;
}
change your 'childname' class to this:
.childName {
/* Behind Image */
position: relative;
z-index: 0;
line-height: 90px;
/* In Center */
text-align: center;
/* Nice handwriting font */
font-family: 'Luckiest Guy', cursive;
The trick here is the lineheight :)

Line break in my Navigation bar in Chrome but not Firefox

Here is the page in questions: http://www.jacobsievers.com/sample.html
In Firefox and IE, My navigation bar displays correctly, but if you look at it with Chrome there is a line break after 'Gallery'. I'm wondering if someone can help me figure out what I need to do or change in my code. Something with the nav ul or nav li in my css?
(source: jacobsievers.com)
(source: jacobsievers.com)
I don't know how to make those scroll box things that other people put code in so here are some jpgs sorry! Thanks for the help.
nav ul {
text-align: center;
width: 700px;
margin: auto;
word-spacing: 50px;
padding: 0;
font-size: 20px;
}
Should fix it :)
EDIT:
/************************ =Nav ************************/
nav ul {
text-align: center;
width: 700px;
margin: auto;
padding: 0;
font-size: 20px;
}
nav li {
display: inline;
margin: auto;
position: relative;
top:30px;
margin-left: 100px;
}
nav li:first-child { margin-left: 0px; }
nav a {
text-decoration: none;
color: rgb(50, 140, 204);
transition: background-color 2s;
-moz-transition: background-color 2s;
/* Firefox 4 */
-webkit-transition: background-color 2s;
/* Safari and Chrome */
-o-transition: background-color 2s;
/* Opera */
transition: color 2s;
-moz-transition: color 2s;
/* Firefox 4 */
-webkit-transition: color 2s;
/* Safari and Chrome */
-o-transition: color 2s;
/* Opera */
}
nav a:hover {
background-color: #E0EEEE;
color: black;
}
jsFiddle - http://jsfiddle.net/andyjh07/cqZTV/