Creating Interactive Bootstrap Cards: A Step-by-Step Guide

I'm having trouble making bootstrap cards clickable on my website. When I try to wrap the boxes with an "ahref" link, it causes a lot of styling issues and makes the boxes smaller. I've tried various solutions but can't seem to figure out why I'm facing this problem.

You can check out some tests I've done at https://codepen.io/snarex/pen/ebQdgj.

section {
    padding-top: 4rem;
    padding-bottom: 5rem;
    background-color: #f1f4fa;
}
.wrap {
    display: flex;
    background: white;
    padding: 1rem 1rem 1rem 1rem;
    border-radius: 0.5rem;
    box-shadow: 7px 7px 30px -5px rgba(0,0,0,0.1);
    margin-bottom: 2rem;
}

.wrap:hover {
    background: linear-gradient(135deg,#6394ff 0%,#0a193b 100%);
    color: white;
}

.ico-wrap {
    margin: auto;
}

.mbr-iconfont {
    font-size: 4.5rem !important;
    color: #313131;
    margin: 1rem;
    padding-right: 1rem;
}
.vcenter {
    margin: auto;
}

.mbr-section-title3 {
    text-align: left;
}
h2 {
    margin-top: 0.5rem;
    margin-bottom: 0.5rem;
}
.display-5 {
    font-family: 'Source Sans Pro',sans-serif;
    font-size: 1.4rem;
}
.mbr-bold {
    font-weight: 700;
}

 p {
    padding-top: 0.5rem;
    padding-bottom: 0.5rem;
    line-height: 25px;
}
.display-6 {
    font-family: 'Source Sans Pro',sans-serif;
    font-size: 1re
<link href="//maxcdn.bootstrapcdn.com/bootstrap/4.1.1/css/bootstrap.min.css" rel="stylesheet" id="bootstrap-css">
<script src="//maxcdn.bootstrapcdn.com/bootstrap/4.1.1/js/bootstrap.min.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<!------ Include the above in your HEAD tag ---------->

<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css"><link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css">

<section>
<div class="container">


<div class="row mbr-justify-content-center">

            <div class="col-lg-6 mbr-col-md-10">
                <div class="wrap">
                    <div class="ico-wrap">
                        <span class="mbr-iconfont fa-volume-up fa"></span>
                    </div>
                    <div class="text-wrap vcenter">
                        <h2 class="mbr-fonts-style mbr-bold mbr-section-title3 display-5">Stay <span>Successful</span></h2>
                        <p class="mbr-fonts-style text1 mbr-text display-6">Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum</p>
                    </div>
                </div>
            </div>
            <div class="col-lg-6 mbr-col-md-10">
                <div class="wrap">
                    <div class="ico-wrap">
                        <span class="mbr-iconfont fa-calendar fa"></span>
                    </div>
                    <div class="text-wrap vcenter">
                        <h2 class="mbr-fonts-style mbr-bold mbr-section-title3 display-5">Create
                            <span>An Effective Team</span>
                        </h2>
                        <p class="mbr-fonts-style text1 mbr-text display-6">Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum</p>
                    </div>
                </div>
            </div>
            <div class="col-lg-6 mbr-col-md-10">
                <div class="wrap">
                    <div class="ico-wrap">
                        <span class="mbr-iconfont fa-globe fa"></span>
                    </div>
                    <div class="text-wrap vcenter">
                        <h2 class="mbr-fonts-style mbr-bold mbr-section-title3 display-5">Launch
                            <span>A Unique Project</span>
                        </h2>
                        <p class="mbr-fonts-style text1 mbr-text display-6">Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum</p>
                    </div>
                </div>
            </div>
            <div class="col-lg-6 mbr-col-md-10">
                <div class="wrap">
                    <div class="ico-wrap">
                        <span class="mbr-iconfont fa-trophy fa"></span>
                    </div>
                    <div class="text-wrap vcenter">
                        <h2 class="mbr-fonts-style mbr-bold mbr-section-title3 display-5">Achieve <span>Your Targets</span></h2>
                        <p class="mbr-fonts-style text1 mbr-text display-6">Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum</p>
                    </div>
                </div>
            </div>

            

            
        </div>

</div>

</section>

Answer №1

If you want to improve the appearance of your a tags, consider setting their position property to absolute, as shown below:

HTML

<div class="wrap">
  <a href="#"></a>
</div>

CSS

.wrap{
  position: relative;
}
.wrap a{
  position: absolute;
  width:100%;
  height:100%;
  top:0px;
  left:0px;
}

Now, the a tag will overlay your card and adjust in size with the card when necessary. Additionally, you can apply border-radius to match the corners of your card.

I have also made updates to your CODEPEN so you can view the changes using the inspector tool for better understanding.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

It appears that using "object[prop]" as a name attribute does not function properly in HTML

After using console.log on the req.body I received this output: [Object: null prototype] { 'shoe[name]': 'Shoe Name', 'shoe[description]': '', 'shoe[pictures]': '', 'shoe[collections] ...

Finding the difference between a PHP date and a JavaScript date

I am currently working on a project using PHP Laravel framework and VueJS. I need to calculate the time difference between the server time and client time in order to process certain data timeouts using JavaScript on the client browser. Can someone guide ...

In search of a fresh and modern Facebook node template

I've been on the hunt across the internet for a quality node.js Facebook template, but all I seem to stumble upon is this https://github.com/heroku/facebook-template-nodejs. It's okay, but it's built using express 2.4.6 and node 0.6.x. I wan ...

How can I ensure that the div remains fixed on scroll and appears directly below the navigation bar, rather than at the top of the page?

There is a div (#callback) that loads asynchronously via ajax upon submit, for updating or deleting an item. It appears as the green message box at the top of the page. Click here to see image and this is how it looks when "scrolling": Check out the scrol ...

Tips for dividing searchable characteristics into distinct search boxes in Algolia

Is it possible to have two <SearchBox /> components, with one searching only on the "title" attribute and the other searching only on the "category" attribute in Algolia admin? Currently, the <SearchBox /> component from react-instantsearch-do ...

Insufficient Resources Error (net::ERR_INSUFFICIENT_RESOURCES) encountered while executing jQuery script with multiple ajax requests for 2 minutes

Upon initially loading the code below, everything seems to be functioning smoothly with the dayofweek and hourofday functions. However, shortly thereafter, the browser (Chrome) freezes up and displays the error message: net::ERR_INSUFFICIENT_RESOURCES. Thi ...

Unable to locate the specified environment variable in the current nest

Currently, I am referring to the official documentation on the NestJs website that provides a guide on using config files: https://docs.nestjs.com/techniques/configuration Below is the code snippet I am working with: app.module import { Module } from &ap ...

The route in my Node.js Express application appears to be malfunctioning

I am facing an issue with my app.js and route file configuration. Here is my app.js file: const express = require('express'); const app = express(); const port = process.env.PORT || 8080; const userRoute = require('./routes/user.route' ...

What is the best way to access a variable within the .each() function in jQuery?

One common dilemma often faced is figuring out how to ensure that markup remains accessible within the scope of this .each() function. Instead of focusing solely on resolving this specific issue, my interest lies more in discovering a method to access ext ...

Steps for adding a class to an element in VueJS

https://codepen.io/nuzze/pen/yLBqKMY Here's my issue at hand: I currently have the following list stored in my Vue data: { name: 'Camp Nou', id: 'campNou' }, { name: 'Abran cancha', id: 'abranCancha ...

What are some methods for creating full-page background images?

I attempted to apply a background image to the body element using the following CSS code: body { background: url("http://beerhold.it/1024/800") center bottom; z-index: 10; height: 100%; background-repeat: no-repeat; ...

Sending a Single Input Field value to a Controller in Laravel using JQuery

Looking to submit a single form value using jQuery to a database in Laravel. Below is the input field: <input type="text" id="comment"> <button id="cmntSubmit" type="button">Post</button> Check out the jQuery code I am using: $(docum ...

Stopping HTML Attribute Enveloping Through Format Adjustments

Having trouble with code formatting where attributes of HTML tags are being wrapped to new lines when formatted, making it hard to read. Is there a way to prevent this from happening? https://i.sstatic.net/LwoOh.png ...

Is there a way to ensure that one ajax call finishes before initiating another?

I'm currently developing a flask application that includes a form with an associated JavaScript function. function applyQueries() { // Performs certain actions if(currentCatalog != ''){ addCatalogFilters(currentC ...

Unexplained absence of componentWillUnmount in React Native component lifecycle

On my Android device, I've noticed that when I exit the application using the hardware back button, the componentWillUnmount function is triggered. However, if I use the square button to show the list of running apps and swipe to close it, the functio ...

I seem to be facing an issue in my Reactjs script, but the exact cause of the problem eludes me

I'm currently coding in React and I have an icon that I want to add a hover effect to, similar to CSS. However, I need to achieve this within my React application. Below is the code snippet I've been working on: import React from 'react&apo ...

The error message "Assignment to a non-variable" pops up in an unexpected scenario

Consider two variables a (which can be either undefined or an Object) and b (always an Object). If a.foo exists, the goal is to assign its value to b.foo. The intention is to achieve this in a single line expression, utilizing logical && operators ...

Experiencing difficulties with exporting data to CSV using MUI DataGrid. How can I ensure that the Excel sheet contains accurate data instead of displaying [Object object]?

Having trouble with exporting to CSV as I am encountering a pesky issue. Instead of the desired value, all I see is [Object object]. Even after implementing the valueGetter method as suggested in the documentation, it does not seem to resolve the problem. ...

Issue with React ChartJS rendering – Title not visibleWhen using React Chart

I'm currently using react chart js for displaying a doughnut in my component. "chart.js": "^3.7.1", "react-chartjs-2": "^4.1.0", However, I'm facing an issue where the title is not being displayed: const d ...

The jQuery autocomplete feature seems to be malfunctioning as no suggestions are showing up when

I am currently generating input text using $.each: $.each(results, function (key, value) { if (typeof value.baseOrSchedStartList[i] != 'undefined') { html += "<td><input type='te ...