I'm creating my first HTML website using Bootstrap, and I have been following this template: Freelancer - Start Bootstrap.
I've been able to customize the template to fit my needs for the most part. However, I have not been able to figure out how I can make it so that when I hover over a picture, you get the color overlay and the YouTube logo appears, and then when you click on the transparent overlay, the link opens.
With the template I'm using, there is an example of this, included below, but instead of a modal opening when you click on the overlay, I want an external URL to open. To do this, I thought I could just change the href to point to the external URL, but this doesn't seem to work. I can right click and open in a new window, but clicking on the overlay does nothing.
Image with overlay & logo:
<div class="col-md-4 col-lg-3">
<a class="portfolio-item d-block mx-auto" href="#s-sign">
<div class="portfolio-item-caption d-flex position-absolute h-100 w-100">
<div class="portfolio-item-caption-content my-auto w-100 text-center text-white">
<i class="fa fa-search-plus fa-3x"></i>
</div>
</div>
<img class="img-fluid" src="img/project/s_sign.png" alt="">
</a>
</div>
Modal that pops up when clicked on:
<div class="portfolio-modal mfp-hide" id="s-sign">
<div class="portfolio-modal-dialog bg-white">
<a class="close-button d-none d-md-block portfolio-modal-dismiss" href="#">
<i class="fa fa-3x fa-times"></i>
</a>
<div class="container text-center">
<div class="row">
<div class="col-lg-8 mx-auto">
<h2 class="text-secondary text-uppercase mb-0">Decorative Sign</h2>
<hr class="star-dark mb-5">
<img class="img-fluid mb-5" src="img/project/s_sign.png" alt="">
<p class="mb-5">The frame is made from poplar. The slats are red oak. The "S" is MDF and was cut out by hand.</p>
<a class="btn btn-primary btn-lg rounded-pill portfolio-modal-dismiss" href="#">
<i class="fa fa-close"></i>
Close Project</a>
</div>
</div>
</div>
</div>
</div>
My attempt to modify the href to point to an external URL instead of the modal section:
<div class="col-md-6 col-lg-4">
<a class="projects-item d-block mx-auto" href="https://youtu.be/qXev3N5QE9A">
<div class="projects-item-caption d-flex position-absolute h-100 w-100">
<div class="projects-item-caption-content my-auto w-100 text-center text-white">
<i class="fa fa-youtube fa-3x"></i>
</div>
</div>
<img class="img-fluid" src="img/youtube/tote.png" alt="">
</a>
</div>
I know how to make it so I can click on the image, and the URL opens, as seen below, but I want to have the overlay and logo appear when hovering.
<div class="col-md-6 col-lg-4">
<a class="nav-link external" href="https://youtu.be/zjTrW9-GrSs">
<img class="img-fluid" src="img/youtube/tote.png" alt="">
</a>
</div>
However over image to reveal overlay, can right-click to open, but cannot click to open:
This might get you started.
Within your bootstrap column, create a container div that is the approx shape of the images/overlays you wish to move one on top of the other.
Within the container div, which should be made position:relative, make two more container divs, both position:absolute (so then can sit exactly one on top of the other)
Inside each pos:abs container div go your specific image and your youTube logo/overlay.
Then you can use javascript/jquery to swap them around on hover (or mouseenter/mouseleave).
$('.myImg').mouseenter(function(){
$(this).fadeOut();
$(this).next().fadeIn();
});
$('.ytLogo').mouseleave(function(){
$(this).fadeOut();
$(this).prev().fadeIn();
});
$('.ytLogo').click(function(){
$(this).find('a').click();
});
.ytContainer{position:relative;}
.myImg{position:absolute;height:50px;width:50px;}
.ytLogo{display:none;}h
.w-100{width:100px;}
.h-100{height:100px;}
.fa{width:100px;height:100px}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<link rel="stylesheet" href="//netdna.bootstrapcdn.com/font-awesome/4.3.0/css/font-awesome.min.css">
<div class="col-xs-6 col-md-6 col-lg-4">
<div class="ytContainer">
<div class="myImg">
<img class="img-fluid ytImg" src="http://placeimg.com/100/100/animals" alt="">
</div>
<div class="ytLogo">
<a class="projects-item d-block mx-auto" href="https://youtu.be/qXev3N5QE9A">
<div class="projects-item-caption d-flex position-absolute h-100 w-100">
<div class="projects-item-caption-content my-auto w-100 text-center text-white">
<i class="fa fa-youtube fa-3x"></i>
</div>
</div>
</a>
</div>
</div>
</div>
Related
I have a issue with vertical alignment in a container. I have the following code that does what I want, that is, the first row in the center and the second at the bottom of the container.
Full screen
<header class="masthead" id="home">
<div class="container h-100">
<div class="row h-100 align-items-center justify-content-evenly text-center">
<div class="col-4">
<img src="assets/img/profil.png" class="rounded-circle img-fluid" alt="...">
<hr class="divider" />
<h1 class="text-white font-weight-bold">d3vyce</h1>
</div>
<div class="col-md-8 col-lg-4">
<h2 class="text-white font-weight-bold">Hi 👋, Welcome to my Site!</h2>
<p class="text-white">Developer, CTF Player, Homelab, 3D Printing</p>
<hr class="divider" />
<div class="d-grid col-6 mx-auto">
<a class="btn btn-outline-light btn-lg" href="https://blog.d3vyce.fr" target="_blank"><i class="fa fa-bookmark fa-lg"></i> Blog</a>
<a class="btn mt-2 btn-outline-light btn-lg" href="https://github.com/d3vyce" target="_blank"><i class="fa fa-github fa-lg"></i> Github</a>
</div>
</div>
</div>
<div class="row head-row justify-content-center">
<div class="col-12 mouse_scroll p-0">
<a href="#about">
<div class="mouse">
<div class="wheel"></div>
</div>
<div>
<span class="m_scroll_arrows unu"></span>
<span class="m_scroll_arrows doi"></span>
<span class="m_scroll_arrows trei"></span>
</div>
</a>
</div>
</div>
</div>
</header>
For the alignment at the bottom of the second row I use the following CSS:
.mouse_scroll {
display: block;
width: 24px;
height: 100px;
position: absolute;
bottom: 0; }
The problem happens with the responsive. The columns of the first row are well one on top of the other, but the space between the two is much too important and I can't modify it :(
I tried to search on stackoverflow for answers, but after many tests I'm in a dead end...
Reponsive
Thank you in advance for your answers!
This is how It must looks like:
here is the image , circle is a place where phtoto must be uploaded
<div class="container ">
<div class="row mx-auto">
<div class="col ">
<span class="border border-success rounded-circle">
<button class="btnUpload">
<i class="fa fa-upload"></i> Upload
</button>
</span>
</div>
</div>
</div>
First of all: use "className" instead of "class" when working with react. To your problem: span is an inline element and doesn't have border. Turn it into a block element by setting display to block or use div element instead. Then center button vertically and horizontally inside of it, for example with flexbox:
<div
className="border border-success rounded-circle"
style={{ width: 100, height: 100, margin: 50 }}
>
<div className="h-100 d-flex justify-content-center align-items-center">
<button className="btnUpload">
<i class="fa fa-upload"></i> Upload
</button>
</div>
</div>
https://codesandbox.io/s/white-http-wsy881
edit: I realise it's probably an issue with position-relative. But not sure how to edit it, changing to sticky, absolute, fixed hurt more than helped.
edit2: The page is the homepage, https://credence.co.uk
I have been optimising a website for Lighthouse and things are generally good but the CLS is awful, and almost entirely caused by one part of the audit:
Lighthouse Report: CLS focus
I'm not sure what's causing this. I see it load in first, but the gallery image above it loads after, which seems to cause it to reload and thus the CLS? Could this be a problem with lazyloading? Or could it be due to the "fade from up"?
Here is the full HTML code for the section in question:
<section id="" class="appseo-service-section position-relative">
<div class="container">
<div class="appseo-service-content">
<div class="row justify-content-center">
<div class="col-lg-4 wow fadeFromUp cefd3ad" data-wow-delay="00ms" data-wow-duration="1500ms">
<div class="appseo-service-box position-relative">
<div class="appseo-service-icon-text position-relative">
<a href="https://credence.co.uk/background-screening-checks/">
<div class="appseo-service-icon position-relative text-center"><i aria-hidden="true" class="fas fa-dice-d20 "></i></div>
</a>
<div class="appseo-service-text appseo-headline pera-content text-center">
<h3>Background Screening Checks</h3>
<p>UK & International Checks</p>
</div>
</div>
</div>
</div>
<div class="col-lg-4 wow fadeFromUp 679b377" data-wow-delay="00ms" data-wow-duration="1500ms">
<div class="appseo-service-box position-relative">
<div class="appseo-service-icon-text position-relative">
<a href="https://credence.co.uk/industry-specific-checks/">
<div class="appseo-service-icon position-relative text-center"><i aria-hidden="true" class="appilo appilo-icon-paper-plane"></i></div>
</a>
<div class="appseo-service-text appseo-headline pera-content text-center">
<h3>Industry Specific Checks</h3>
<p>Airside, FCA, BS7858 & BPSS</p>
</div>
</div>
</div>
</div>
<div class="col-lg-4 wow fadeFromUp 3a81a52" data-wow-delay="00ms" data-wow-duration="1500ms">
<div class="appseo-service-box position-relative">
<div class="appseo-service-icon-text position-relative">
<a href="https://credence.co.uk/hr-services-solutions/">
<div class="appseo-service-icon position-relative text-center"><i aria-hidden="true" class="fab fa-searchengin"></i></div>
</a>
<div class="appseo-service-text appseo-headline pera-content text-center">
<h3>HR Services & Solutions</h3>
<p>JobValidate & Exit Interviews</p>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="appseo-service-vector" data-parallax='{"y" : 100, "rotateY":500}'>
<img src="" alt>
</div>
</section>
I'm using materialize cards for my webpage, the idea is to use the cards as menus so when a person click in any part of the card the link should open. But it is only working by clicking in the image and/or in the text but no in any other part of the card.
This is the code:
<div class="col l6 m12 s12">
<a href="signup.html" target="_blank">
<div class="card cardHover">
<div class="card-image waves-effect waves-block waves-light">
<img class="activator" src="img/test2.jpg">
</div>
<div class="card-content">
<span class="card-title activator text-darken-4">RoboTico<i class="material-icons right">build</i></span>
</div>
</div>
</a>
</div>
The code above I know is going to work only with the image and the text. But I tried to make all the card as a link like
<a href=""> <div class="col l6 m12 s12">
<a href="signup.html" target="_blank">
<div class="card cardHover">
<div class="card-image waves-effect waves-block waves-light">
<img class="activator" src="img/test2.jpg">
</div>
<div class="card-content">
<span class="card-title activator text-darken-4">RoboTico<i class="material-icons right">build</i></span>
</div>
</div>
</a>
</div>
But it didn't work.
try making an href tag absolute on every card try this :
div.col{position:relative}
.fullcard{position:absolute;
top:0;
left:0;
width:100%;
height:100%;
display:inline-block;
z-index: 99999;}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
<!-- Compiled and minified CSS -->
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/materialize/0.100.2/css/materialize.min.css">
<!-- Compiled and minified JavaScript -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/materialize/0.100.2/js/materialize.min.js"></script>
<div class="col l6 m12 s12">
<a href="signup.html" target="_blank">
<div class="card cardHover">
<div class="card-image waves-effect waves-block waves-light">
<img class="activator" src="http://pixdaus.com/files/items/pics/6/20/107620_cb8da068c718b9e6aa7aa0bcbc68d18f_large.jpg">
</div>
<div class="card-content">
<span class="card-title activator text-darken-4">RoboTico<i class="material-icons right">build</i></span>
</div>
</div>
</a>
</div>
If you set the a to be style display:block and then wrap everything in it - you should be able to click anywhere in the card and navigate to the new link. The reason why you currently have to click on the elements is that a's are inline level elements and only respond to direct interaction on them - you need to set it to become a block level element and to therefore respond to any interaction within that block.
I added a couple of style rules to highlight this (such as border and padding) and doing it this way means that you only need to have a single a in each card. Note that I don't have your image - so the alt text shows up here.
.display-card {
border: solid 1px #333;
}
.nav-link {
display:block;
padding:15px
}
<div class="col l6 m12 s12 display-card">
<a href="signup.html" target="_blank" class="nav-link">
<div class="card cardHover">
<div class="card-image waves-effect waves-block waves-light">
<img class="activator" src="img/test2.jpg" alt="image">
</div>
<div class="card-content">
<span class="card-title activator text-darken-4"> RoboTico <i class="material-icons right">build</i></span>
</div>
</div>
I know it's strange, but I've take the code with a menu bar whitout nav tag ..
What I would like : Have a hamburger icon (it's ok). When the user click on it, the menu slide down slowly (I'm using slideToggle function with jQuery).
For that, the menu has to be hidden, but if I hide it in small screen (phones) it's also hidden on large screen !
What I have : This code :
<div class="col-xs-1 hidden-sm hidden-md hidden-lg">
<span id="hamburger"><i class="fa fa-bars fa-2x" aria-hidden="true"></i></span>
</div>
<div class="col-xs-12 col-sm-8 menu-nav hidden-xs">
<div class="row text-center">
<a href="{{ path('jt_concours_index') }}">
<div class="col-md-2 col-sm-2 botborder concours"><span class="menu_valign">le concours</span>
</div>
</a>
<a href="#">
<div class="col-md-2 col-sm-2 botborder nos-produits"><span class="menu_valign">nos produits</span>
</div>
</a>
</div>
</div>
JS :
$('#hamburger').on('click', function(){
if ($('.menu-nav').hasClass('hidden-xs')){
$('.menu-nav').removeClass('hidden-xs');
} else {
$('.menu-nav').addClass('hidden-xs');
}
$('.menu-nav').slideToggle('slow');
});
But it's not working .. Have an idea ?
EDIT
I finally used collapse class from bootstrap, like this :
<button class="toggle" data-toggle="collapse" data-target=".menu-nav">
<span id="hamburger"><i class="fa fa-bars fa-2x" aria-hidden="true"></i></span>
</button>
<div class="col-xs-12 col-sm-8 menu-nav collapse">
<div class="row text-center">
<a href="{{ path('jt_concours_index') }}">
<div class="col-md-2 col-sm-2 botborder concours"><span class="menu_valign">le concours</span>
</div>
</a>
<a href="#">
<div class="col-md-2 col-sm-2 botborder nos-produits"><span class="menu_valign">nos produits</span>
</div>
</a>
And now it's working fine. Thanks :)
did you try to change it from display: none to eg display: block instead of working with the hidden-nn classes? you could also create your own hidden class for it.