What causes the contents of a container div to be shifted below the div itself?

I am attempting to create a circular border around an emoji, contained within a span inside a div.

The 50% radius border should appear on hover, which it does, but the content in the span gets pushed below the div. Refer to the screenshot provided.

<div className={styles.emojiContainer} key={index}>
   <span className={styles.emoji} role="img" aria-label={feeling} onClick={handleClick}>😄</span>
   <p>happy</p>
</div>

CSS:

.emojiContainer {
  display: flex;
  flex-direction: column;
  align-items: center;

  p {
    margin-top: 1rem;
  }
}

.emoji {
  display: inline-block;
  border-radius: 50%;
  font-size: 3.5rem;
  height: 3.5rem;
  width: 3.5rem;
}

.emoji:hover {
  border: 4px solid #2773e2;
}

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

Answer â„–1

After some experimentation, I found that the best solution was to simply incorporate a text-shadow:

.emoji:hover {
  text-shadow: 4px 0 #2773e2, -3px 0 #2773e2, 0 4px #2773e2, 0 -4px #2773e2,
               3px 3px #2773e2, -3px -3px #2773e2, 3px -3px #2773e2, -3px 3px #2773e2;
}

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

How to create a scrollable card within a div using bootstrap

How do I create a scrollable card in Bootstrap 4 with this specific HTML structure: <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSA ...

Animating links with multi-line effects on :before.orEnhancing

As per the given query, I have a code snippet Is there any way to apply this effect to multiple lines of text instead of just one line? Currently, the effect only appears on one of two text lines (as shown in the example). :root { --00a3a3: #00a3a3; ...

Can you identify the method used to apply CSS classes to an element?

Looking for clarification, I've noticed a pattern of "adding" (although unsure if that's the correct term) classes to elements in HTML UI frameworks. For instance, considering an element with these class attributes: class="mif-earth mif-2x" To ...

Applying SVG filters in conjunction with CSS transitions

While working on an SVG filter with CSS animation, I utilized the following code: <svg xmlns="http://www.w3.org/2000/svg" version="1.1"> <defs> <filter id="goo"> <feGaussianBlur in="SourceGraphic" stdDeviation="10" result= ...

Find a solution for displaying custom product badges

Having some issues with a custom product badge on my website. I tried adding a new badge (besides "Sale"), but it seems to be displaying in the wrong position. The badge should display as "Choice" on the featured products, so I added this code to the chil ...

Creating a modal popup when a button is clicked

After searching online for a way to make my sign up modal pop up when the signup button in my navbar is pressed, I was unable to find any information on how to achieve this. I suspect it involves JavaScript, but my knowledge of JS is limited. I attempted ...

Responsive Line Breaks in Bootstrap 4

I can't seem to find any information in the documentation to guide me in the right direction here. I'm hesitant to use columns as it could result in gaps between the text. Currently, I have the date displayed at the top of my website like this u ...

JavaScript code to always keep the element on top of the page: "Make

I have developed a straightforward chrome extension tool that displays a small text message (a div with z-index 999999) on the webpage that the user is currently viewing. However, I am facing a problem where the div sometimes gets hidden beneath the existi ...

Adding borders to div elements for mobile display

Almost done with my website homepage, but I'm noticing some pesky borders/outlines on mobile devices. This issue doesn't seem to pop up on computers, so you'll need an iPhone, tablet, or smartphone to see what I'm talking about. Check o ...

What is the best way to reset an event back to its original state once it has been clicked on again

As a newcomer to web development, I'm currently working on creating my own portfolio website. One of the features I am trying to implement is triangle bullet points that can change direction when clicked - kind of like an arrow. My idea is for them to ...

Moving image transitions on the screen using CSS3

Looking for a demonstration of an image sliding in from the left of the screen, pausing in the center for a brief moment, and then continuing across the page. Any ideas on where to find this? Appreciate it, Adam ...

Tips for Creating an Upward-Dropping Dropdown Menu in HTML/JavaScript When Space is Limited on the Page

Hello, I am currently seeking a solution to adjust my dropdown menu so that it appears above instead of below when the page doesn't have enough space to display it fully. My tools for this project include HTML, Javascript, CSS, and JQuery exclusively. ...

Apply CSS3 attributes in real time

The for loop I have is functioning properly: <div id="page1div"></div> <script> list = " "; for (var i = 0 ; i < length ; i++) { list = "<h1 class='entriesdisplayed'>" + item(i) + ...

Adjust Vue FilePond dimensions

I am currently working with a Vue Filepond and trying to ensure that it fills the height of its container. My Vue Filepond setup also involves Vuetify. Whenever I attempt to set values in the CSS, they are constantly overridden by 76px. Although fill-hei ...

Utilize Rails file_field input as a clickable button

Currently, I have a button that needs to trigger the action associated with a file_field in my Rails application. Below is the erb code I am using: <label for='file-input'> <span class='btn btn-success' style='max-width ...

Express template failing to connect with scripts, css, and images

When using Express, I encounter difficulty in getting the css, js, and images to link up correctly when running the index.html file. The images are not showing up and the css and js files are not linking properly. <link rel="stylesheet" type="text/css" ...

Require the capability to bypass inline CSS styling

Currently facing an issue with a wordpress website I am constructing using iThemes Builder. The problem arises when integrating the plugin Jquery Megamenu, as the drop-down menu gets truncated due to an overflow:hidden property that cannot be overridden i ...

Unable to interact with element within an iframe during automated testing

I've been struggling with this issue for two days now and I just can't seem to solve it. I'm working on an automation Proof of Concept project (although I doubt I'll get the job) where I need to automate a task on an Oracle page. The p ...

Issue with Hidden Horizontal Scrollbar Functionality in JQuery Mobile Not Resolving

http://jsbin.com/UREQUbu/1/edit I have a header with 9 buttons. I managed to get the horizontal scrollbar to work, but I want it hidden yet still scrollable. I came across a JQuery plugin that worked perfectly for scrolling on my laptop, but unfortunately ...

What is the best way to make a CSS class appear in my javascript using the method I have been using before?

I am facing an issue in making this code work properly. It functions correctly for my caption element as there is only one caption tag in my HTML. However, the same code does not work for my TR element since it requires a for loop to iterate through multip ...