As the screen size decreases, the div's position shifts accordingly

1- When the cursor hovers over the icon, a tooltip appears. However, as the screen shrinks slightly, the position of the div changes. How can I prevent this?

EDIT: Simply adding margin: auto; and transform: translateX(-250px); properties to the .installmentinfo__container class resolved the issue.

2- Another question I have is regarding the positioning of the tooltip that opens below the icon. How can I ensure there is no space between the dropdown and the icon?

Note: The tooltip should appear at the bottom left of the icon.

I managed to fix the second problem mentioned above.

Refer to the image below for context:

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

html

<div className="installmentinfo__container">
  {
    props.installmentList?.map((e, i) => {
      return (
        <div className="installmentinfo">
          <div className="column">
            <div className="installmentnumber" >{(i + 1).toString()}</div>
            <div className="installmentdate">{e.date}</div>
            <div className="installmentamount">{e.amount} {e.currency}</div>
          </div>
        </div>
      );
    })
  }
</div>

css

.installmentinfo__container {
  border: 1px solid #d1d1d1;
  border-radius: 10px;
  max-width: 300px;
  box-shadow: 2px 2px 4px 4px #d1d1d1;
  position: absolute;
  right: 340px;
  background-color: white;

  &:last-of-type {
    border-bottom: none;
  }

  .installmentinfo {

    width: 280px;
    height: auto;
    padding: 0em 1em;

    .column {
      display: flex;
      margin: 5px;
      justify-content: space-between;
      font-size: 1.3rem;
      border-bottom: 1.5px solid #d1d1d1;
    }

    .installmentnumber {
      float: left;
    }

    .installmentdate {
      width: 50%;
      color: black !important;
    }

    .installmentamount {
      width: 50%;
      color: black !important;
      font-weight: 1000;
    }
  }
}

Answer №1

Understanding these code examples can be quite challenging at first glance.

It seems that the issue may be related to the value of "right: 340". Without a parent element with "position: relative", the current element will consistently shift 340px from the right.

To resolve this, consider assigning "position: relative" to the parent element containing ".installmentinfo__container". Once done, you can then utilize "right: 0".

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

Employing CSS animations to elevate div elements

Currently, I am working on animating a table of divs and trying to achieve an effect where a new div enters and "bumps up" the existing ones. In my current setup, Message i3 is overlapping Message 2 instead of bumping it up. How can I make Messages 1 and 2 ...

What is the best way to arrange the keys of a javascript object in descending order?

I'm dealing with a JavaScript object structured like this: data: { 474481: { date: "02/14/2017", status_id: "474481" ​​ }, 497070: { date: "02/14/2017", status_id: "497070" }, 797070: { date: "02/14/2017", status_id: " ...

Click on the hamburger to trigger the CSS transition

The objective of my project is to create an interactive hamburger icon that transforms into a cross when clicked, and reverts back to its original state on a second click. While I have successfully implemented a transition on hover and click through resea ...

Encountering the message "Source: ERROR" while using React Native's WebView

Attempting to load a screen in a React Native WebView using a POST method has encountered an issue with the code snippet below: <WebView source={{ uri: 'https://esqa.moneris.com/HPPDP/index.php', method: 'POST', body: &a ...

Having issues getting the DataTables responsive feature to work in my sails.js and angularjs project

I've successfully imported the required DataTables css and js files. <link rel="stylesheet" href="/bower_components/bootstrap/dist/css/bootstrap.min.css"> <link rel="stylesheet" href="/bower_components/datatables-plugins/integration/bootstr ...

"Ensuring content remains within the confines of a modal box

My goal is to integrate a month calendar pop-up within my app using a material UI Modal where users can choose the day. However, I am encountering an issue with the size of the modal not adapting to the calendar properly. How can I resolve this? (To open t ...

Looking for assistance with extracting data from a table using beautifulsoup and the selenium webdriver

Currently, I am in the process of web scraping data from . I have successfully managed to navigate through clicks to reach a table. The specific selection I am practicing involves selecting the checkbox for "Employment Cost Index (ECI) Civilian (Unadjuste ...

There seems to be a mysterious issue with the addClass function in jQuery, as it is not behaving

I am facing an issue with the function showColorStart() as it is not working as expected. When this function is called, the background color of the squares should change to the color specified in the array colorspicked[lindex], but it is not doing so. I ha ...

Issue with Retrieving the Correct Element ID in a Loop with JavaScript Function

I'm in the process of developing a dynamic wages table with HTML and JavaScript to compute each employee's wage based on input from each row. In order to achieve this, I've utilized a loop to assign a unique ID to the total cell in every ro ...

Grant authorization for scripts to exclusively operate on Travis CI and not through local execution

I am looking to restrict certain scripts in my .travis.yml file to only run within the Travis CI build environment, and not on a user's local machine. The configuration in the .travis.yml would resemble this: # .travis.yml script: - npm run deplo ...

Instructions on creating a Superfish menu with a vertical layout in the first level and a horizontal layout in the second level

Currently, I am using the Superfish menu in Drupal7 and have designed my first item level to be vertical. However, I now want to style my second item level horizontally. I have tried various CSS approaches and added some class names via jQuery like $(&apo ...

Enter information into the TextArea and jQuery dialog

I require assistance in populating a textarea with data obtained from querying a database. I have a jQuery dialog that contains another dialog, inside of which is a textarea. Here is some pseudocode: <MODAL> <modalB> <TextArea>s ...

Can CSS be used to separate elements within a div from the overall page styles, similar to how an iFrame functions?

Is there a way to isolate elements within a div, similar to how it would behave in an iFrame? I am facing issues with the global SharePoint styles affecting my app inside SharePoint. I want to completely disable these global styles so that my app only use ...

The printing code is not able to interpret the CSS

Having trouble with this script not reading the style properly when printing, can anyone assist in identifying the issue? <script type="text/javascript"> $(function () { $("#btnPrint").click(function () { var contents = $( ...

Recognizing a component through various page loads

The title of this question may not be the best, but I hope my explanation clarifies what I'm trying to achieve. It's 4AM, so please forgive any confusion in my message. What I want to do is identify if a user-selected element appears on any page ...

Extension for web design snippet

My program creates dynamic html documents using specific parameters, but there is one section that remains static and is pulled from a local text file. What would be the most appropriate file extension to use for this particular snippet? htm(l): Although ...

Conditionally display a button utilizing V-IF when a Firestore value evaluates to true

I am fetching data from my Firestore database and displaying them on cards. I want to add buttons to the card only if a specific value in the loaded object is true. { "Alarm": false, "Safety": true, "Battery": true }. For example, if the values are as ab ...

display a discrete delete button when pressing a button within ng-bootstrap

My current setup uses ng-bootstrap with Angular4. Image https://i.sstatic.net/83UhP.png In the interface, a checkbox button is used to show responses fetched from the backend. By clicking the button, the x button disappears along with other elements belo ...

JavaScript: what is the method to add a paragraph when the condition is not met?

I am currently working on a project that involves checking if a student is actively engaged in an online journal. This is done by tracking the student's progress using a unique userId. If the student's userId is not found in the JSON data returne ...

Using angular 7 to apply a dynamic CSS class on a span element

I want to dynamically change the CSS class of a span element in an ngx datatable based on the value. Here is my HTML code: <ngx-datatable #orderinvoice class="bootstrap" [rows]="invoiceSource" [headerHeight]="50" [footerHeight]="50" [rowHe ...