Currently, I am utilizing ELEMENTREF to interact with the DOM via Renderer2. Allow me to provide a simple example:
import { Directive, Renderer2, ElementRef } from '@angular/core';
@Directive({
selector: '[appHighlight]'
})
export class HighlightDirective {
constructor(private renderer: Renderer2, private el: ElementRef) {
this.renderer.setStyle(this.el.nativeElement, 'background', 'yellow');
}
}
The code above was just a demonstration to highlight the syntax in yellow color.
However, I have a query regarding how to access the previous element and retrieve its width in order to set it as the value for a left-style property?
For instance: If the preceding sibling has a width of 400px, I want the current element to have a left style of 400px.
Your collaboration is greatly appreciated.