Tips for showing an icon on top of the react crop component

I'm having trouble displaying an icon over the react crop component. The icon (undo button) is not visible when the react crop component is present, but it appears when I remove it.

My code with the react crop component:

    return (
      <div>
         <div className="webcamCapture">
        { campic}
        </div>
        { buttons}
       
        {this.state.imageData && (
          <>
        {src && (
           <div className="preview">
          <ReactCrop
            src={src}
            crop={crop}
            ruleOfThirds
            onImageLoaded={this.onImageLoaded}
            onComplete={this.onCropComplete}
            onChange={this.onCropChange}
          />
          </div>
        )}
         </>
        )}
      </div>
    )

This is my icon component that I want to display over the react crop:

        <div className="preview">
        <div > 
        <FontAwesomeIcon className="preview__close" icon={faChevronLeft} onClick={() => this.setState({ imageData: null })}/>
       </div>
       </div>

Here is my CSS code:

.preview {
    position: relative;
}

.preview__close {
    position: absolute;
    top: 0;
    margin: 5px;
    cursor: pointer;
    color: red;
}

If anyone can provide assistance, I would greatly appreciate it!

Answer №1

Like I mentioned in my previous remark, it is crucial to include the zIndex attribute in one of your components. For instance:

.specific-class {
    z-index: 10;
}

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

Are element.isEmpty() and element.innerHTML = "" interchangeable?

Can you tell me if the title is accurate? If not, what would be equivalent to setting .innerHTML = "" ? ...

How come the error message in AngularJS is appearing as blank during error handling?

When utilizing AngularJS code to send a request to the server, everything works smoothly on success. However, deliberately redirecting the request to a different domain causes the CORS problem where the error handling function is triggered but errorData ...

Placing a point on a measurement scale according to a changing factor

I am completely new to html, css, and javascript. My goal is to create a color gradient bar and then place a dot on it based on a variable. I tried to implement a solution I found from various sources, but it is not functioning as expected, and I am seekin ...

Tips for managing lag caused by large raw image re-renders in a React application

When trying to change the background position of a user-uploaded background image that is in raw Data URI format using CSS, I noticed that re-rendering becomes slow if the image size exceeds 1mb. This issue does not occur with smaller images. Is there a ...

What could be causing my HTML homepage to not be connected to my CSS file?

I have been researching this issue and none of the solutions I found have worked for me. My HTML page is unable to locate my CSS page even though they are both in the same folder. I am using Dreamweaver but coding from scratch. Below is my HTML code: < ...

What is the process for transforming an AJAX request's onreadystatechange into a promise?

During the process of making a javascript AJAX request, I initially utilized the traditional callback approach to call the callback function within the onreadystatechange and retrieve all the values of readyState. However, upon switching my callback funct ...

Having trouble displaying a background image with CSS

When I open Chrome from my code editor (WebStorm), the header image shows up perfectly. However, after closing WebStorm and manually opening index.html from my project folder, the header image fails to load/display. The CSS for the background image is bac ...

A handy guide to vertically centering an image within a carousel using Bootstrap

Hello, I am a new member of this community and consider myself an inexperienced coder. I have encountered an issue with my carousel images and would like them to be centered by height. The images are larger than the carousel itself, so I want to center ...

Cease the method/interval if the user disconnects or the specified condition is satisfied

My goal is to develop a real-time order tracking page for customers to monitor the progress of their orders. To achieve this, I am planning to implement a function that will run every 10 seconds to query the SQL database and check if the order is ready fo ...

Setting React's PUBLIC_URL dynamically at runtime can be accomplished by manipulating the process.env.PUBLIC

I'm currently working on a new CRA project that will be utilized on a website hosting multiple plugins within an "iframe". These plugins are served using a proxy, and the plugin URLs are unknown until they are instantiated. To retrieve the location o ...

What is the reason for function expressions being hoisted when called within Express JS middleware?

It's common knowledge that function declarations are hoisted, allowing them to be called from anywhere in your script. However, this is not the case for function expressions. For instance: test(); const test = () => { console.log(1+3); } ...

I aim to arrange three div elements in a single row with varying widths - placing one on the left, another in the center, and the last

I am trying to have three div elements in one row with different widths - one on the left, one in the center and one on the right. The left div should be 160px The center div should be 640px The right div should be 160px My goal is for them to appear se ...

Tips for redirecting once a JavaScript timer has run out?

Looking to update the code once the timer (See code) has run out. Currently, I am working on an exciting auction project for a friend and when the timer expires, I want to change the page so that no more bids can be placed. All bids are time-sensitive, so ...

Struggling to accurately differentiate between a CSS and Bootstrap code

I'm attempting to create a visually appealing underline under the active tab, but I am facing challenges in targeting the specific class. Since I am utilizing bootstrap and unable to adjust the width and margin of text-decoration or recognize an eleme ...

What is the best way to position a point slightly off the data points on the axis in ECharts?

I'm not sure if my English is correct, but I really need some assistance. Do you have the necessary data for an Echart graph? option = { xAxis: { data: ['A', 'B' 'B', 'C', 'D', 'E'] ...

Styling input elements with CSS Grid is causing resizing issues specifically in IE11

Encountering issues with CSS Grid in IE11. (not surprising, right?) The grid has 2 columns - the first column contains labels for a form, while the second column holds <input> and <select> elements. All input elements have a size attribute se ...

Combining Update and Select Operations in Knex JS in a Single Query

With Knex JS - Can all elements from the row being updated be retrieved in a single query that combines both update and select operations? Currently, only the id of the updated row is returned by the update operation. let query = await knex('items&a ...

The depth order of overlapping elements and the rotation effect achieved through

I have created some interactive flip cards using CSS and HTML with transitions Currently, when you hover over a card, it flips and enlarges. However, I am facing an issue with positioning the hovered card on top using z-index and relative position due to ...

Node JS does not receive a response from JQuery Ajax

I have developed a form on the client side which includes: <html> <body> <script> $(document).ready(function() { $.ajax({ url: "Search.html", type: "POST", dataType : "json", s ...

Integrate data from Firebase into a React-Table component

I am currently working on a table component that fetches data from Firebase to populate three fields: Name Date Comment For each entry, I want to add a new row. The pivot has been successfully added. However, when trying to populate the table, I am encou ...