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>
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!
I have tried everything I can thing of. And searching Google has not turned up anything.
<div class="col-md-12">
<div class="card-header text-white" style="background-color:cornflowerblue">
<div class="col">
#if (User.Identity.IsAuthenticated && User.IsInRole("Admin"))
{
<a class="text-white float-right" asp-action="Edit" asp-route-id="#item.Id"><i class="bi bi-pencil-square"></i></a>
}
</div>
<div class="col">
<p class="card-text">
<h5 class="card-title">#item.Name</h5>
</p>
</div>
<p class="text-dark">#item.Price.ToString("c")</p>
</div>
</div>
<div class="col-md-6">
Basically what I want is for the bi-pencil-square to float to the right edge of the card header. I have tried Bootstrap float right and style="Margin-Right: 0px". I have tried setting styles on the a tag, on the enclosing div, and even on the i tag. Nothing works.
Does anyone have any suggestions?
I figured it out. I think the problem was that I should have put the 2 div's inside a row tag.
<div class="col-md-12">
<div class="card-header text-white" style="background-color:cornflowerblue">
<div class="row">
<div class="col-md-1 offset-11">
#if (User.Identity.IsAuthenticated && User.IsInRole("Admin"))
{
<a class="text-white" asp-action="Edit" asp-route-id="#item.Id"><i class="bi bi-pencil-square"></i></a>
}
</div>
<div class="col card-text">
<h5 class="card-title">#item.Name</h5>
</div>
</div>
<p class="text-dark">#item.Price.ToString("c")</p>
</div>
</div>
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 was working with bootstrap and found out a weird issue. When using collapse button, page width is changed (changes to lower), when I press collapse again to hide the shown content, page is reset to normal. What can be causing the issue?
<a class="btn btn-icon btn-light" data-toggle="collapse" href="#article-content1" role="button" aria-expanded="false" aria-controls="article-content1">
<i class="fas fa-minus"></i>
</a>
<div class="collapse" id="article-content1">
<div class="card-body">
You can show or hide this card.
</div>
<div class="card-footer">
<div class="container-fluid">
<div class="row">
<div class="col-1">
<img alt="image" src="./assets/img/avatar/avatar.png" class="rounded-circle avatar-outline ml-autox" alt="" width="46" height="46" style="margin-top:-3px">
</div>
<div class="col-6 text-left">
<strong>Jasmine Snow</strong></br>
<span class="color-muted">November 11, 2020</span>
</div>
<div class="col-5"><!-- empty --></div>
</div>
</div>
</div>
</div>
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>