Issue with absolute positioning in Primeng components when a p-selectButton is added

I'm just starting to explore primeng, and I encountered this html snippet:

<div class="main wheel">
    <div class="wheel-part use">
       <img src="./assets/images/svg/path-use.svg">
       <span class="wheel-part-title">USE</span>
    </div>
</div>

Accompanied by the following CSS:

.wheel {
    height: 37.5vh;
    width: 39vh;
    text-align: center;
    margin-left: auto;
    margin-right: auto;
    position: relative;
    background-color: #008800;
  }

  .wheel .use {
    position: absolute;
    top: 20px;
    right: 0;
    background-color: red;
  }

Initially, the output looked like this:

https://i.sstatic.net/42mHN.png

My issue arose when I added a p-selectButton element to the HTML, causing the positioning to no longer work as expected.

The updated HTML code with the p-selectButton:

<div class="main wheel">
   <p-selectButton [options]="wheelParts" multiple="multiple" > ;
      <ng-template let-wheelPart let-i="index" pTemplate="item">
         <div class="wheel-part use">
            <img src="./assets/images/svg/path-use.svg">
            <span class="wheel-part-title">USE</span>
         </div>
      </ng-template>
   </p-selectButton>
</div> 

Resulting layout after introducing p-selectButton:

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

For more details, check out the StackBlitz

Answer №1

When you include the

<div class="wheel-part use">
within your primeNg element, accessing the class is not as straightforward. The new way to access it is by using :host ::ng-deep

Unfortunately, the stackblitz seems to be outdated, preventing me from testing the exact syntax. You can try something similar to this:

:host ::ng-deep .use {
    position: absolute;
    top: 20px;
    right: 0;
    background-color: red;
}

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

Position the Bootstrap right column to align absolutely on the right side of the page with no padding

I need assistance in designing a row with two columns. I am looking to align the right column to the right side of the page without using container-fluid. Can someone please help me with this? Thank you https://i.sstatic.net/4kh9O.jpg ...

Learn how to access an array within an object using JavaScript and an API URL

Trying to fetch data from the swapi API to display film titles using jQuery. Below is the JavaScript code: $(function(){ function promiseTest(){ return $.ajax({ type: 'GET', url: 'https://swapi.co/api/people/', } ...

Angular UI modal backdrop provides a way to create a customizable

Having trouble with an angular ui modal - a white rectangle appearing between the modal and backdrop. Any suggestions? var modalInstance = $modal.open({ templateUrl:'src/app/shared/confirm-modal.html', controller: ...

Puppeteer's flawed performance leads to the generation of low-quality

Currently, I am utilizing puppeteer to generate a PDF from my static local HTML file. However, the resulting PDF is turning out to be corrupted. When attempting to open the file using Adobe Reader, an error message pops up stating 'Bad file handle&apo ...

I am experiencing some issues with my AngularJS JavaScript code. The root scope is updating correctly, but the other two scopes are not working as expected. Can

My attempt at writing AngularJS JavaScript code seems to be malfunctioning. While the root scope updates properly, the other two scopes FirstCtrl and SecondCtrl do not update as expected when the root scope is updated. I would like all three scopes to upd ...

Redirecting visitors based on window size

I have created three individual pages for screen resolutions of 1024, 768, and 320 width. Is there a method to automatically direct the visitor to the appropriate page based on their screen resolution? The main reason I am not developing a responsive webs ...

Contact form in Bootstrap 5 lacks responsiveness

I am currently exploring Bootstrap 5 for my website design project, and one of the features I have implemented is a contact form. While the white arrow that separates the two sections blends in seamlessly on desktop and laptop screens, it doesn't quit ...

Resolving the issue of 'type' property missing but required in 'SeriesXrangeOptions' within the Angular Highcharts module

I'm attempting to showcase a price chart view for a specific cryptocurrency chosen from a list of cryptocurrencies, but I keep encountering a type mismatch error. Within my application, I have utilized the angular-highcharts module and brought in the ...

The variable ApiAIPromises is not recognized within the context of Ionic 3 and Dialogflow

I am currently integrating dialogflow into my ionic app. Below is the code snippet from my .ts file: import { Component, NgZone } from '@angular/core'; import { IonicPage, NavController, NavParams } from 'ionic-angular'; declare v ...

Is it possible to customize the color of an SVG image within Next.js using next/image?

import Image from 'next/image' ... <Image src="/emotion.svg" alt="emtion" width={50} height={50} /> I am trying to change the color of the SVG using next/image. However, applying the following CSS rule does not seem ...

Tips for creating a dashed border line that animates in a clockwise direction when hovering

I currently have a dashed border around my div element: .dash_border{ border: dashed; stroke: 2px; margin:20px; } My goal is to make the dashed lines move clockwise when my pointer hovers over the div element and stop moving ...

Utilizing the indexOf method to filter an array in a Next.js application with TypeScript

I have two arrays in my Next.js app Array 1: [ { identifier: "60a17722225f2918c445fd19", name: "Ben Awad", _id: "60c94480b8d43c28d0a6eb73 }, { identifier: "60a455d11fa62a1510b408f8", name: ...

Utilizing a personalized class to enhance the aesthetic of VMware's clarity dark theme

I've been experimenting with the dark theme feature in VMware Clarity to toggle between light and dark themes. However, I'm encountering an issue where the dark theme isn't being applied to my custom CSS classes, which is to be expected. F ...

What is the best way to ensure a div spans the entire width of the screen?

I came across a helpful post on extending my container to the edge of the screen. Despite following the instructions, I still noticed a white space (highlighted in red): https://i.sstatic.net/w0bGf.png To address this issue, I experimented with setting t ...

Tips on setting a value to zero in Angular when there is no input

Is there a way to organize the data and show the PRN entries based on the date, for instance, when the month is January? If there is data for machine 1 with assetCode: PRN, it should be displayed under the header for children. Similarly, if there is data f ...

Is it possible to utilize a DIV or SPAN value for JQuery plugin options?

I have integrated a Twitter plugin into my website with the following settings: jQuery(function($){ $(".tweet").tweet({ username: "username", count: 3, template: "{avatar}{text}{time}", loading_text: "loading tweets..." ...

Turning off CSS on a Wordpress page

I need some assistance with WordPress and CSS. By default, WordPress applies CSS to all posts and pages. However, I want to disable specific CSS styles for certain objects on the page. For example: When I insert a table, it automatically inherits the CSS ...

How can I address the variations in CSS appearance between Firefox and Google Chrome?

I'm currently working on a table with two cells in each row just for fun. For the first row, I want both cells to display the same picture. To achieve this, I wrote the following CSS: tr:nth-child(1){ background-image:url("cat.jpg"); background-size: ...

The WordPress website showcases inline CSS code

I'm currently working on a project at and upon reviewing the source code, I noticed the following snippet. This inline code is part of the Theme, and I'm wondering if there's a way to extract this code into a separate stylesheet within the ...

What could be causing this issue? Do you think I'm headed in the right direction?

Can someone assist me with troubleshooting my "getTutorNames" method? I've encountered an error message in my program that seems to be related to a variable being defined twice. The full problem description can be found in the provided link. I have be ...