Experiencing difficulties with the alignment of different elements using CSS

In my latest game project, I have designed a battle scenario where three players with unique avatars face off against each other.

However, I am encountering an issue. When a character is targeted by a skill that lasts for multiple turns, an image representing that skill appears at the top left of their avatar (unlike the enemy team where the images are floated to the right as shown here: prntscr*com/6d354s).

The problem arises when hovering over these effect images, as they trigger a pop-up container displaying the effect description. While I have successfully implemented this feature, the positioning is incorrect - the effect description should appear next to the effect icon but is not aligning correctly on the right side.

On the left side, I managed to achieve the desired result using CSS hover properties as showcased here: prntscr*com/6d34a2 and http://prntscr.com/6d33zy

<div>
  <a class="tooltip">
  <img class="effect-icon">
  <div class="effect-description">
       <h1></h1>
       <p></p>
   </div>
   </a>
</div>

In the code snippet above, I utilize position relative on the effects container while keeping the effect description hidden with display: none; and floating both elements to the left. By setting

.tooltip:hover div{display: inline-block; position:absolute;}
in the CSS file, the effect description is displayed and positioned adjacent to the image icon without affecting other images, similar to this showcase: prntscr.com*6d3ihu

Although this method works well for the left side, it poses challenges on the right side where the div containing the effect description gets pushed away from the effect icon...

Can someone provide assistance with this issue? :(

For reference, here is an example provided on CodePen: http://codepen.io/anon/pen/jEpgbX. I aim to have the effect description on the right side display to the left of the icon.

Answer №1

It's hard to provide a concrete solution without witnessing the issue firsthand, but perhaps adjusting the left and right properties of .effect-description could help.

For example:

.tooltip {display: inline-block;}
.tooltip:hover div{ display: inline-block; position: absolute; top: 0 }
.l .tooltip:hover div {left: 50px;}
.r .tooltip:hover div {right: 50px;}

UPDATE: Upon reviewing your CodePen demo, I have refined my response and created a fork of your pen to illustrate my suggestion http://codepen.io/anon/pen/OPwKbE

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

Ensure to verify the presence of a null value within the ngFor iteration

I have a webpage where I am displaying information in buttons. These buttons show various objects from a list along with their corresponding fields (e.g. object.name, object.age, etc.). Sometimes, one of those fields is null. How can I check if a value is ...

Loading HTML dynamically

Currently, I am working with node.js, express, and handlebars. When passing JSON data via res.render() to handlebars (hbs), I use {{#each dataJson}} to loop through the data and display it. However, if my JSON file had a large number of entries, loading t ...

Using JavaScript, a checkbox can be employed to insert text into a textarea

I have a simple Javascript task that I'm trying to accomplish without using JQuery. My goal is to toggle the text in a textarea based on the state of a checkbox. When the checkbox is unchecked, I want the textarea to display "Hello", and when it' ...

Create a password variable while typing

Looking to avoid interference from browsers with autocomplete and password suggestions while maintaining the show/hide letters feature. The goal is to keep the password stored as a variable, regardless of whether the characters are shown or hidden. The is ...

How do I attach an event listener to a select box that is created dynamically using JavaScript?

I'm new to web development and I'm currently working on a project where I need to create a select box dynamically within a div that is also created dynamically when the page loads. However, I'm facing an issue with adding an onchange Event L ...

Troubleshooting Google Tag Manager in Google Tag Assistant with the GTM script enclosed in an iframe on a separate domain

Recently, I have encountered a strange problem with the GTM's debugging feature. It was working perfectly fine before the interface got revamped. Previously, all I needed to do was enter the URL of the website and the debugger would successfully conn ...

Adjusting the size of elements and the dimensions of the browser window

My challenge involves a container with multiple buttons that are absolutely positioned. I would like these buttons to dynamically resize based on the width of the browser window. Essentially, I want both the size and position of the buttons to adjust accor ...

Issue with Smooth Div Scroll on Chrome

I'm currently utilizing a plugin called Smooth Div Scroll, which can be found at Despite the automatic scrolling functionality working perfectly on Firefox, IE, and Safari, I'm encountering an issue with it not initiating when the page loads in ...

Issue with form not being validated

I'm attempting to disable the submit button when a user enters something in the email field, but despite validation, it is not working as expected. What could be the issue with my validation code? function validateEmail(email) { var btnSubmit = ...

Exploring the concept of module patterns in JavaScript

Currently, I am working on honing my JavaScript skills as I am relatively new to the language. I am attempting to identify the specific element that triggered an event and display it within a span element. However, I seem to encounter an issue as clicking ...

What causes the image size to stay the same when the screen width is less than 300px?

I have been facing an issue with my website where it appears fine on desktop screens but doesn't adjust properly on smaller devices like mobile phones. I've tried using "clamp" for the width property in CSS, but the problem persists. The content ...

What could be causing my slider to malfunction?

No errors are being returned by the console. Currently utilizing Unslider. The setup includes: <div class="slider"> <ul> <li><img src="img/one.jpg" alt=""></li> <li><img src="img/one.jpg" ...

What is the best way to center a text and a rectangle (containing some text) on a page using Bootstrap?

I'm in the process of creating a webpage using HTML and CSS that needs to look exactly like this image: https://i.sstatic.net/wYKZw.png Currently, I have a version of it on JSFiddle. The issue with the JSFiddle version is that the text and rectangle ...

Mobile operating system "curtain" design on Android

I want to design a menu that functions similar to the Android notification drop-down section (where you pull down from the top). This menu should have its own scrollbar, incorporate images, and have smooth animations when scrolling down instead of jumping ...

Utilizing jQuery for seamless transitions between multiple background images

Looking to create a dynamic page using jQuery that alternates between different large background images for a fading effect. How can I achieve this? ...

What is the origin of the character?

Currently running a string test. When I obtain the innerHTML, there are unexpected u'\n and \n', AssertionError: u'\n<p><strong>The user/password code entered is incorrect!</strong></p>\n' != ...

The text element does not line up with the icons

As I'm working on creating my first account page header, I've run into an issue with some of the icons not aligning perfectly with the text. While advanced developers may find this task simple, as a beginner, I could really use some advice on how ...

Update various components within a container

I have incorporated a function that automatically loads and refreshes content within a div every 10 seconds. Here is the script: $(function () { var timer, updateContent; function resetTimer() { if (timer) { window.clearTimeout(timer); ...

Issues with padding in the h1 title of a mobile website

I am currently working on creating a mobile-friendly version of a website. However, I am facing an issue where the background image set for an H1 title is only taking into account the "text height" and not the actual picture height specified in the CSS. A ...

Shifting a div element using Jquery towards the left side

Hey there, I'm new to this web design thing and I recently tried creating my own website. I stumbled upon a fantastic Slider Menu on this website: http://tympanus.net/codrops/2010/06/28/awesome-cufonized-fly-out-menu/ The only issue I'm facing i ...