Elevate a div above the rest when it is selected or dragged

I am facing an issue with draggable divs inside a parent container. Each div has a popup edit panel to modify its content. The problem arises when the divs overlap, causing the edit panel to get hidden behind another div. I want to ensure that whenever a div is clicked or dragged, it appears on top along with its edit panel. How can I resolve this?

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

<div ng-repeat="node in nodes track by $index" ng-if="node!==undefined">
    <div class="node" id="node{{node.id}}">
        <div ng-include="'components/nodeTemplate.html'"></div>
        <div ng-include="'components/editContent.html'"></div>
    </div>
</div>
.node{
    width: max-content;
    position: absolute !important;
    border-radius: 5px;
    left: 15px;
    top: 15px;
    display: flex-row;
    justify-content: center;
    align-items: center;
}
.edit-panel{
    font-weight: 400;
    font-size: 15px;
    position: absolute;
    background-color: #fff;
    width: 300px;
    padding: 20px;
    border-radius: 10px;
    left: 430px;
    top: 160%;
    transform: translate(-50%,-50%);
    box-shadow: 0 4px 8px 0 rgba(0, 0, 0, 0.2), 0 6px 20px 0 rgba(0, 0, 0, 0.19);
}

Answer №1

To achieve the desired effect, a combination of CSS and Angular is required in this scenario:

  1. Utilize Angular to append an active class to your node element if it represents the last node that was interacted with, for example:
    class="node {{lastInteraction(node.id)?'active':''}}"
    (you could utilize ng-click to update variables used by lastInteraction())
  2. Apply styling to .node.active including a z-index value to ensure it appears above other elements

For further details on z-index, you can refer to: https://developer.mozilla.org/en-US/docs/Web/CSS/z-index

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

What could be causing this jQuery color picker to malfunction when used inside a Bootstrap modal?

Currently, I am utilizing the fantastic jQuery color picker provided by Although it functions as expected in "normal" scenarios, I have encountered an issue where the picker fails to display when the input parent element is nested within a Bootstrap 3 mod ...

Error alert: The system could not locate Google when trying to drop pins

Every time I attempt to place pins on the map, I encounter the "google is not defined" error. The map itself displays without any issues until I add the lines following the initMap() function. I have come across similar posts but none of the suggested so ...

Is it possible to connect an AJAX function to a hyperlink for it to function properly?

I am looking to track the number of clicks on outgoing links on my website, without using Digg-like links or redirects. My idea is to use a jQuery function that will call a PHP script via AJAX to update the click counter for each link when clicked. I have ...

Navigating advanced search through nuanced filters dynamically with AngularJS

Here you will find the advanced search form: https://i.stack.imgur.com/g7Hiz.png I have successfully created a URL and parameters for document sections, but I am struggling to come up with a solution for managing the "Add Property Restrictions" section w ...

How can Javascript or Jquery determine the specific event assigned to an object?

Is it possible to retrieve the properties of HTML elements using their name or id? For example: document.getElementById('id').value; //Accessing element property in JavaScript $('#id').attr('class'); // Accessing correspond ...

Unique markers for Google Maps

I have been working on creating custom Google maps with the concept of incorporating 3 distinct markers such as forests, rivers, and lakes. While I have successfully added these custom markers using a helpful tutorial, I am now facing a challenge with sor ...

Is it advisable to set the html root at 62.5% when using rem units in CSS? Does this imply that the default font size of browsers is 16px?

During a discussion with a group, I mentioned the 62.5% trick for scalability (setting 62.5% as font size in root and using rem units throughout CSS for easier scalability when users change default browser font size) and their arguments were as follows: " ...

The jQuery function that clears the form data

I have a webpage where clicking on a link changes the content of a div using the following code. The content is filled out using page1.php, which includes a form with dropdown lists. However, whenever I try to select something from a dropdown list, it res ...

Trouble with Gulp and Browserify

Recently, I started diving into the world of gulp and browserify. Here's the setup in my gulpfile.js: gulp.task('default', function (done) { var b = browserify({ entries: ['app/app.js'], }); var browserifie ...

Vue: Simple ways to retrieve state data in MutationAction

I'm having trouble accessing the state inside @MutationAction Here is the setup I am using: Nuxt.js v2.13.3 "vuex-module-decorators": "^0.17.0" import { Module, VuexModule, MutationAction } from 'vuex-module-decorators' ...

How Jquery Can Be Used to Dynamically Add Extra Rows in HTML Without Submitting Data via POST Requests

When using jQuery to dynamically add extra rows to an HTML table, I encountered an issue where the fields of the extra rows were missing in the $_POST array when submitting the form. Can you please review the code and provide a solution to fix this problem ...

Forced line break at particular point in text

I would love to implement a line break right before the "+" character, either using css styling or through a different method. Is this task achievable? #myDiv{ width: 80% } #myP{ c ...

Acquiring JSON information using AJAX

I'm struggling to retrieve variables from a JSON URL and use them as jQuery strings. Despite trying different methods, I haven't been successful. Attempt 1 $.getJSON('http://radio.silvertoneradio.com/rpc/incoleyl/streaminfo.get', ...

How do I repeatedly invoke a function in JQuery that accepts two different arguments each time?

I have a collection of folders, each containing various images. The number of pictures in each folder ranges from 8 to 200. Folders are numbered from 1 to 20 and the images within them are also labeled numerically. My goal is to aggregate all these images ...

Removing an element in Vue.js

Can someone help me with a Vue.js issue I'm having? I'm working on a quiz and I want to add a button that deletes a question when clicked. Here's what I've tried so far: deleteQuestion(index) { this.questions.splice(index, ...

AngularJS issue: [filter:notarray] The expected data type was an array, but instead received: {} while using a filter within an ng

I'm working on populating an HTML table by making an angular request to an API using the ng-repeat directive. The HTML page loads first, and then the data is fetched from the API to fill the table once the response is received. When I include a filter ...

Can a function be appropriately utilized in a reducer?

For my reducer, I am looking to incorporate a function that is necessary for sorting. I have successfully imported this function from another file and it seems to be functioning correctly. However, I am unsure about the validity of importing and using fu ...

Angular button press

Recently, I started learning Angular and came across a challenge that I need help with. Here is the scenario: <button *ngIf="entryControlEnabled && !gateOpen" class="bottomButton red" (click)="openGate()">Open</button> <button *ngIf ...

Comparing Traditional Tables to Div Tables

Is this process: <table> <tr> <td>Hello</td> <td>World</td> </tr> </table> Achievable with the following code? <div> <div style="display: table-row;"> <di ...

Delete one item from a group of objects[]

In my TypeScript code, I have a declared object like this: public profileDataSource: { Value: string, Key: number }[]; This results in an object structure that looks similar to the following: 0: Object {Value: "<Select Profile>", Key: null} ...