Magnific popup is not functioning when I add hover - text on image - html

I want to add a text when the user hover the mouse on my image gallery and zoom the when they clicked it. It already zooming in but when I add a class and text between the image class the magnific popup is not working. It seems like the text is blocking the image to be selected. I don't know how and what to change. Thanks!
Image Gallery Code:
$(".container").magnificPopup({
delegate: 'a',
type: 'image',
gallery:{
enabled: true
}
});
.box{
width: 270px;
height: 250px;
position: relative;
background-color: rgba(255,102,104,1.00);
margin: 10px auto;
cursor: pointer;
}
.box img{
max-width: 100%;
height: 100%;
object-fit: cover;
}
.box:hover::after{
transform: scale(1, 1.05);
}
.con-text{
position: absolute;
color: white;
bottom: 0;
width: 270px;
height: 250px;
padding: 75px 25px;
display: none;
text-align: center;
}
.box:hover .con-text{
display: block;
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<div class="container">
<div class="box">
<a href="https://cdn.pixabay.com/photo/2014/08/21/14/51/pet-423398__180.jpg" class="image">
<img src="https://cdn.pixabay.com/photo/2014/08/21/14/51/pet-423398__180.jpg" alt="image">
</a>
<div class="con-text"> // Magnific popup doesn't work anymore when I add this div
<h2>Title</h2>
</div>
</div>
</div>

Related

How to fix this image size issue inside the modal?

img1
img2
When you click on the modal it opens the image like lightbox but the problem is that it's scrollable as well as images don't fit the screen. Here is the code:
HTML
<div class='row'>
<div class='col-md-3 img-content' *ngFor="let image of images let i = index">
<img (click)="openModal();currentSlide(i+1)" class="hover-shadow cursor img-responsive"
src="http://res.cloudinary.com/dfg5p1pww/image/upload/v{{image.imgVersion}}/{{image.imgId}}">
</div>
</div>
<div id="myModal" class="slide-modal">
<span class="close cursor" (click)="closeModal()">×</span>
<div class="slide-modal-content">
<div class="mySlides" *ngFor="let image of images let i = index">
<img class="img-responsive1" src="http://res.cloudinary.com/code/image/upload/v{{image.imgVersion}}/{{image.imgId}}" style="width:100%">
</div>
<a class="prev" (click)="plusSlides(-1)">❮</a>
<a class="next" (click)="plusSlides(1)">❯</a>
<div class="caption-container">
<p id="caption"></p>
</div>
<div class="slide-column" *ngFor="let image of images let i = index">
<img (click)="currentSlide(i+1)"
class="img-responsive" src="http://res.cloudinary.com/code/image/upload/v{{image.imgVersion}}/{{image.imgId}}" style="width:100%">
</div>
</div>
</div>
CSS
.slide-column {
float: left;
width: 25%;
}
.slide-modal {
display: none;
position: fixed;
z-index: 1;
padding-top: 10px;
left: 0;
top: 0;
width: 100%;
height: 100%;
overflow: auto;
background-color: black;
}
.slide-modal-content {
position: relative;
background-color: #fefefe;
margin: auto;
padding: 0;
width: 90%;
max-width: 1200px;
}
.close {
color: white;
position: absolute;
top: 10px;
right: 25px;
font-size: 35px;
font-weight: bold;
}
.mySlides {
display: none;
}
.prev,
.next {
cursor: pointer;
position: absolute;
top: 50%;
width: auto;
padding: 16px;
margin-top: -50px;
color: white;
font-weight: bold;
font-size: 20px;
transition: 0.6s ease;
border-radius: 0 3px 3px 0;
user-select: none;
-webkit-user-select: none;
}
.next
{
right: 0;
border-radius: 3px 0 0 3px;
color:#ffffff !important
}
.prev {
left: 0;
border-radius: 3px 0 0 3px;
color:#ffffff !important
}
img {
margin-bottom: -4px;
max-width:100%;
}
.img-responsive {
width: auto;
height: 250px;
}
.img-responsive1
{
height:100%;
width:auto;
vertical-align: top;
}
The problem is inside those classes slide-modal, slide-modal-content, img-responsive1
Also in the above images, you can see how does it look like? We use Bootstrap 4 in this project with Angular. How to fix the size of the modal and make it to fit the full screen and at the same time allow images to fit to the screen (without scrolling and if image is long then change the width for showing it correctly instead of changing just height in such a way as it's shown in the image)?
I would consider using Bootstrap's built-in CSS classes for responsiveness as opposed to rolling your own CSS selectors. Responsiveness, in Bootstrap, is based on screen width not height since Bootstrap utilizes width-based CSS Media Queries. This will solve the issue with the horizontal scroll for your images since images will automatically scale to their parent container's width. To make your images responsive in Bootstrap simply apply the .img-fluid class to them:
<img src="..." class="img-fluid" alt="Responsive image">
This .img-fluid class is a good default for your images moving forward so they never overflow your parent container's width.
Directly from Bootstrap's documentation:
"Images in Bootstrap are made responsive with .img-fluid. max-width: 100%; and height: auto; are applied to the image so that it scales with the parent element."
Hopefully that helps!

How to fix 'Hover text to image, text keeps it's original position and img changes in background'

I'm creating a webpage and was wondering when I hover over a part of text (in span) how I can keep it in it's position and make the image appear in the background, so the text can go over it.
HTML:
<html>
<link REL=StyleSheet HREF="HOVERTEST_02.css" TYPE="text/css" MEDIA=screen />
<h1>FS STUDIO</h1>
<h2><span>Automation(FS1920)</span>.
<img src="https://www.applerubber.com/blog/wp-content/uploads/2015/07/Float_Glass_Unloading.jpg"/>
</h2>
<h2><span>Platforms(1819)</span>
<img src="https://njmonthly.com/wp-content/uploads/cache/2018/11/Amazon_AFradkin_4440b/1072634020.jpg"/>
</h2>
CSS:
img{
display:none;
}
span:hover + img{
display: block;
margin-left: auto;
margin-right: auto;
margin-top: auto;
margin-bottom: auto;
height: 600;
width: device-width;
opacity: 0.8;
}
For image not to change the text position, you need to set position: absolute.
Like this, the image will ignore the other elements in the page and will let text be shown, see the quick demo above:
UPDATED VERSION
img{
display:none;
width: 50vw;
height: 40vw;
position: absolute;
top: 5vh;
right: 10vw;
}
span:hover + img{
display: block;
margin-left: auto;
margin-right: auto;
margin-top: auto;
margin-bottom: auto;
height: 600;
width: device-width;
opacity: 0.8;
}
<h1>FS STUDIO</h1>
<h2><span>Automation(FS1920)</span>.
<img src="https://www.applerubber.com/blog/wp-content/uploads/2015/07/Float_Glass_Unloading.jpg"/>
</h2>
<h2><span>Platforms(1819)</span>
<img src="https://njmonthly.com/wp-content/uploads/cache/2018/11/Amazon_AFradkin_4440b/1072634020.jpg"/>
</h2>
you mean this right?
span.one:hover{
background-image: url('https://www.applerubber.com/blog/wp-content/uploads/2015/07/Float_Glass_Unloading.jpg');
}
span.two:hover{
background-image: url('https://njmonthly.com/wp-content/uploads/cache/2018/11/Amazon_AFradkin_4440b/1072634020.jpg');
}
<h1>FS STUDIO</h1>
<h2><span class="one">Automation(FS1920).</span>
</h2>
<h2><span class="two">Platforms(1819)</span></h2>

Hide/show text on hover

Hello I'm trying to hide / display an absolute positioned text on image hover with transform scale effect and shadowing background I had some problems with z-index and div containers. What I'm trying to achive is:
Before hover:
On hover:
I know I could wrap text into div and then change visibility or display css property on hover but it doesn't work for me. Here is my code:
<div class="container-fluid">
<div class="row">
<div class="col-md-6 col-lg-4 column" *ngFor="let clientProject of clientProjects; let i= index">
<button class="btn button-modal" data-toggle="modal" [attr.data-target]="'#' + i">
<span class="hidden-text">TEXT</span>
<img src="{{clientProject.clickImageButtonPath}}" class="img-fluid image">
</button>
</div>
</div>
</div>
css:
.image {
width: 100%;
height: 400px;
transition: all 0.3s ease-in-out;
z-index: 1;
opacity: 0.35;
}
.button-modal {
padding: 0 !important;
overflow: hidden;
background-color: black;
}
.button-modal:hover {
padding: 0 !important;
}
.hidden-text:hover + .image,
.image:hover {
transform: scale(1.2);
}
.column {
margin: 0 !important;
border: none;
padding: 0 !important;
}
.hidden-text {
display: block;
z-index: 2;
color: white;
font-size: 2rem;
border: none;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
margin: 0;
position: absolute !important;
}
Could someone help with this please?
I'm not sure what you're trying to do exactly, so I think it would be good to figure out what element you want to trigger the action on, then tell that element to hide and show the text. I'm also not sure if you're trying to do this all CSS or not, but I would typically do something like this. Be aware that this is jQuery, which I assume you're using if you're using bootstrap, and this is just an example of what you can do with a simple bit of jQuery code in this example. Here's a link to a working fiddle http://jsfiddle.net/aq9Laaew/110775/ and here's the code I used to achieve the result:
$('.button-modal').hover(function(event){
$(this).find('.hidden-text').show();
},function(){
$(this).find('.hidden-text').hide();
});
jQuery hover handler is actually 2 functions inside, one for mouseover (hover start) and one for mouseout (hover end), and it makes this easy, so you can do one thing on the start (show your text) and another on the end (hide your text) all in a nice little packaged function. You can also split these out and do mouseover and mouseout individually. I would also edit your CSS a little if you're going to use this approach, like this:
.button-modal:hover {
padding: 0 !important;
transform: scale(1.2);
}
.column {
margin: 0 !important;
border: none;
padding: 0 !important;
}
.hidden-text {
display: none;
z-index: 2;
color: white;
font-size: 2rem;
border: none;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
margin: 0;
position: absolute !important;
}
Try this:
<style type="text/stylesheet">
.container:hover #cts {
display: block;
}
</style>
<div class="container">
<div class="img" style="position: absolute; width: 500px; height: 500px; z-index:0;">
<img src="https://i.stack.imgur.com/Az76Y.png"></img>
</div>
<div id="cts" class="text-box" style="display: none; position: absolute; display: table; margin-left: auto; margin-right: auto; background: rgba(0,0,0,0.4); text-align: center; height: 500px; width: 500px; z-index: 1; transition: all .3s ease;">
<div class="text-box-inner" style="display: table-cell; height: 500px; width: 500px; vertical-align: middle; margin-left: auto; margin-right: auto;">
<span class="text" style="color: #fff;">ANY TEXT</span>
</div>
</div>
</div>
<script type="text/javascript">

image hover overlay, ahref on second click needed for mobile website

EDITED:
1) desktop size: hover overlay works, a click on img leads to the website.
2) mobile size: hover doesn't work, a click on img does both overlay and goes straight to the website (I don't want that).
3) I want mobile size to behave ALMOST same as desktop size, overlay then a second click to lead to the website.
Tried: Added second ahref "Click to enter" inside IMAGE while having first ahref with "#/" for overlay purpose, doesn't work. Any better solution?
https://jsfiddle.net/6ro92ao9/
HTML
<div class="gallery">
<a href="http://codepen.io/ngarciaiii/full/Vjwjbp/">
<img src="http://i.imgur.com/0IGbqui.jpg" alt = "Web Ex1" class="image">
<div class="overlay">
<h2 class="text">HTML5 CSS3</h2>
</div>
</a>
</div>
CSS
.gallery {
position: relative;
width: 320px;
margin-right: auto;
margin-bottom: 15px;
margin-left: auto;
}
.image {
display: block;
width: 320px;
height: 200px;
}
.overlay {
position: absolute;
top: 0;
bottom: 0;
left: 0;
right: 0;
height: auto;
width: 100%;
opacity: 0;
transition: .5s ease;
background-color: black;
}
.gallery:hover .overlay {
opacity: .8;
}

Hover event taking place outside of area I am wanting

I have a small bug that I can't seem to locate. In my snippet you can see how whenever you hover over the image, opactiy and an image scale takes place, as well as a box comes over the image. That is perfect, but my issue is whenever you hover over the text below it, the hover effect takes place over the image.
I can't seem to figure out how for the hover effect to only take place when the mouse is hovering over the image.
Any suggestions would be appreciated.
$('.home-img-block img').addClass(function() {
return (this.width / this.height > 1) ? 'wide' : 'tall';
});
#home-img-block-section {
width: 100%;
height: 900px;
}
#home-img-blocks {
width: 100%;
height: 750px;
}
.home-img-block {
width: 33.33%;
float: left;
display: block;
overflow: hidden;
position: relative;
}
.home-img-container {
position: relative;
overflow: hidden;
cursor: pointer;
}
.home-img-block:hover .overlay {
background: rgba(0, 0, 0, 0.6);
width: 100%;
height: 100%;
position: absolute;
top: 0;
left: 0;
}
.home-img-container:after {
content: attr(data-content);
color: #fff;
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
opacity: 0;
transition: all 0.5s;
border: 1px solid #fff;
padding: 20px 25px;
text-align: center;
}
.home-img-container:hover:after {
opacity: 1;
}
.home-img-block img {
display: block;
transition: all 1s ease;
}
.home-img-block:hover img {
transform: scale(1.25);
background: rgba(0, 0, 0, 0.3);
width: 33.33%;
max-height: 100%;
overflow: hidden;
}
.home-img-block img.wide {
max-width: 100%;
max-height: 100%;
height: auto;
width: 100%;
}
.home-img-block img.tall {
max-width: 100%;
max-height: 100%;
width: auto;
}
#home-img-block-wording-container {
width: 100%;
height: 300px;
}
.home-img-wording-blocks {
width: 100%;
height: 100%;
text-align: center;
display: inline-block;
vertical-align: top;
}
.home-img-wording-block-title {
padding-top: 30px;
font-size: 1.7em;
}
.home-img-wording-block-description {
padding: 25px 50px 0 50px;
font-size: 1.1em;
color: #5d5d5d;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<div id="home-img-block-section">
<div id="home-img-blocks">
<div class="home-img-block fadeBlock1">
<div data-content="FIND OUT MORE" class='home-img-container'>
<img src="http://optimumwebdesigns.com/images/test1.jpg">
<div class="overlay"></div>
</div>
<div class="home-img-wording-blocks">
<div class="home-img-wording-block-title">WEB DESIGN</div>
<div class="home-img-wording-block-description">The OD team can see your web design visions brought
to life, creating a site that promotes your uniqueness through specific functionalities and features.</div>
</div>
</div>
<div class="home-img-block fadeBlock2">
<div data-content="FIND OUT MORE" class='home-img-container'>
<img src="http://optimumwebdesigns.com/images/test2new.jpg">
<div class="overlay"></div>
</div>
<div class="home-img-wording-blocks">
<div class="home-img-wording-block-title">ECOMMERCE</div>
<div class="home-img-wording-block-description">Custom built solutions catered towards you end goal.
gfdgfdsg greg reg regrfesg fdsg gretswtgy tgreswt treswt trgegfd gsvbd fbgre greasgv drfdg greaag gredr</div>
</div>
</div>
<div class="home-img-block fadeBlock3">
<div data-content="FIND OUT MORE" class='home-img-container'>
<img src="http://optimumwebdesigns.com/images/test3new.jpg">
<div class="overlay"></div>
</div>
<div class="home-img-wording-blocks">
<div class="home-img-wording-block-title">MARKETING STRATEGIES</div>
<div class="home-img-wording-block-description">MARKETING STRATEGIES gfdgf fdggs gfsg gfsg gf sgf g
gfdsg sdfggfs gfdsgssdfg fdggfds gfdsg gfds gfdgs gf dsgfdsgfgs gfdgfs gtrg resg reg rgesgresrgrg</div>
</div>
</div>
</div>
</div>
.home-img-block:hover .overlay
and
.home-img-block:hover img
replace them with
.home-img-container:hover .overlay
.home-img-container:hover img
otherwise you're triggering when you hover over the whole container instead of only wheen hovering the img one.