The red solid outline of 1px is not functional when attempting to enlarge on hover

Recently, I stumbled upon a PSD design that really caught my eye.

https://i.sstatic.net/R46Ko.jpg

It inspired me to create a website similar to . One feature I particularly liked was how a circle appeared when hovering over a link. Plus, I plan on using Bootstrap 4.5 for this project.

Here's the CSS snippet I'm considering:

ul.navbar-nav > li > a {
    padding: 60px 0 16px;
    text-align: center;
    position: relative;
    min-width: 110px;
}

/* Additional CSS code here */

I also found a simple HTML example that aligns perfectly with what I have in mind:

<li class="nav-item active">
    <a class="nav-link" href="#">
        <i class="fas fa-th-large fa-2x"></i>
        <span>Home</span>
    </a>
</li>

For further inspiration, I checked out this demo as well:

https://i.sstatic.net/SoXI1.png

Answer №1

To create a circular border around an icon when hovering over a button, you can use CSS pseudo classes. By adding a hover psuedo class to the button and setting a border-radius of 50% along with a border on the icon, you can achieve this effect. In the provided example, a span tag is used for the icon: ul li a:hover span:first-of-type. When hovering over the 'a' tag, the span:first-of-type, which represents the icon, will be affected. Some adjustments may be needed in your CSS, but hopefully, you get the idea of how this can be implemented using CSS hover effects.

For animation, include the @keyframes rule in your CSS for the pseudo element. In this example, two animations are added with the same duration - one for the 'a' tag's background-color and color, and another for the pseudo element ':after' using the 'opacity' property. The ':after' pseudo element allows the original image icon to remain visible without being impacted by the opacity setting during the animation.

* {
  padding: 0;
  margin: 0;
}

a {
  text-decoration: none;
}

ul li a {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 10px;
  width: 100px;
  border-radius: 10px 10px 0 0;
}

ul li a:hover {
  animation: fadebg 0.8s ease-in-out;
  background-color: #800080;
  color: #FFF;
}

@keyframes fadebg {
  from {
    color: #000;
    background-color: #FFF;
  }
  to {
    color: #FFF;
    background-color: #800080;
  }
}

ul li a span:last-of-type {
  margin-top: 5px;
}

ul li a:hover span:first-of-type:after {
  content: '';
  animation: fadein 0.8s ease-in-out;
  width: 50px;
  height: 50px;
  position: absolute;
  border: 1.5px solid white;
  border-radius: 50%;
  align-content: center;
  left: 32px;
  padding: 2px;
  opacity: 1;
}

@keyframes fadein {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

.icon {
  width: 50px;
  height: 50px;
}

li span {
  display: block;
}

li {
  list-style-type: none;
}
<ul>
  <li class="nav-item active">
    <a class="nav-link" href="#">
      <span><img class="icon" src="https://cdn2.iconfinder.com/data/icons/minimal-set-two/32/minimal-39-128.png"></span>
      <span>Home</span>
    </a>
  </li>
</ul>

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

The animation fails to function, both when hovering over and when not

ul { display: flex; flex-direction: row; align-items: center; list-style-type: none; background-color: $base-gray-t; margin: 1em; padding: .25em 0 0 0; height: 3em; border-bottom: 0.375em solid $secondary-color; overflow: hidden; ...

Adjust size of item within grid component in VueJS

I have a grid container with cells and a draggable item in a Vue project. I am trying to figure out how to resize the box inside the grid component (refer to images). https://i.stack.imgur.com/q4MKZ.png This is my current grid setup, and I would like the ...

Can an element on a webpage be dynamically assigned an ID using JavaScript or PHP?

Is it possible to dynamically set the ID of an element during runtime of a webpage? Let's consider this scenario - <body id="body1"> Now, I would like to dynamically set the ID of this "body" element using a variable value in PHP code. Is som ...

Guide to triggering a click event programmatically at specific x and y coordinates using JavaScript

The event api allows for the creation of a synthetic MouseEvent that can be programmatically dispatched by a DOM element. By adding an event listener to the document, you can capture the event dispatched by the child element during the bubble phase. For ...

What is the solution for resolving the "cannot resolve" issue in CSS for an Angular project?

During a small project I was working on, I decided to add a background image to another image using CSS. Here is the code snippet: .child2 img { width: 200px; height: 200px; border-radius: 50%; background-image: url('./assets/images/imageb ...

Tips on adjusting the SVG view box for optimal visibility in a web browser

Recently, I've encountered an issue with the following code snippet: d3.xml("https://crossorigin.me/https://svgshare.com/i/5w9.svg").mimeType("image/svg+xml").get(function(error, xml) { if (error) throw error; document.body.appendChild(xml.docume ...

What is the best way to retrieve the input value from post.ejs?

app.js var express = require('express'); var bodyParser = require('body-parser'); var app = express(); var passport = require('passport'); var localStrategy = require('passport-local'); var axios = require("axi ...

Multi-select buttons using Bootstrap

Before, I used standard check-boxes, but now I am looking to switch to using bootstrap Multiple select boxes. However, when I implement the new code, I am unable to see any rows in my drop down. New code snippet: <li> <select href="#" class="se ...

How can I automatically disable certain checkboxes when a specific radio button is selected?

Looking to disable certain checkboxes when a specific radio button is selected. For instance, selecting the first radio button with the id="pz1" should disable checkboxes with matching id values from the thisToppings array. Each radio button cor ...

`Make Bootstrap 5 Modal centered horizontally`

I'm facing an issue with my Vue application where the Bootstrap 5 modal is not horizontally centered on desktop. Below is the code snippet of my component: Modal.vue <template> <teleport to="#modal-container"> <div ...

Is there a way to verify the results of a Python script within a PHP webpage?

For my school project, I am creating a PHP website where I want to implement a Python code Quiz. I envision a scenario where users can input Python code in an on-page editor/IDE and the output is checked automatically using PHP If-function to determine cor ...

Angular Navigation Bar with Tab Elements

I'm looking for recommendations on how to create a tabbed navbar in Angular without redirecting to other pages. I want the user to be able to click on a tab and have a specific component displayed without losing any data, as it will be used for an ext ...

Is there a way to modify the browser's user agent using JavaScript or HTML?

I currently have an application that is running on IE7. However, an analytics tool I rely on has recently been updated and now requires a minimum of IE8. Is there a way to modify the User Agent in IE7 using JavaScript or HTML to trick it into being recogni ...

Can Google Charts columns be customized with different colors?

Is it possible to modify the colors of both columns in Google's material column chart? Here is the code I am using for options: var options = { chart: { title: 'Event Posting', subtitle: 'Kairos event p ...

StringBuilder has the ability to handle HTML symbols

My view is supposed to display a drop-down list based on the data sent from the model. @{ StringBuilder sb = new StringBuilder("<select id=\"field"+Model.Id+"\">"); sb.Append("<option>Choose...</option>"); foreach(var s in Mod ...

Tips on extracting the image URL from a canvas element using Selenium in Java and leveraging JavascriptExecutor

My main objective is to extract the image URL from a canvas container. Here is what I have attempted: JavascriptExecutor jse = (JavascriptExecutor) driver; Object imageURL = jse.executeScript("arguments[0].toDataURL('image/png');", canvas); Un ...

Component that dynamically changes background images in Vue

I'm currently working on a Vue banner that requires a dynamic background, but for some reason, it's not functioning as expected. I've experimented with different methods, and using an image tag like this works: <img :src="require(`@/asse ...

I would like to terminate the property when processing it on a mobile device

<div class="col-sm-24 embed-responsive"> <iframe width="100%" src="http://www.youtube.com/embed/${item.snippet.resourceId.videoId}"></iframe> </div> .embed-responsive iframe { height: 185px; margin-top: -4%; paddin ...

Unable to identify the Xpath selector for the "Account settings button" and "find my iPhone" features within iCloud

When trying to access my iCloud account settings and locate the "Find my iPhone" button on iCloud.com, I am encountering issues with my selectors. It seems like there are no frames on the page, but the Xpaths I'm using are not matching. Here are the ...

The navigation bar and text subtly shift when displayed on various devices or when the window size is adjusted

Hello, I am brand new to web development and have encountered an issue on my website. Whenever the window is resized or viewed on a different screen, the navigation bar (which consists of rectangles and triangles) and text elements start moving around and ...