Choosing changeable object label in CSS

Looking for a way to style multiple customized HTML tags (Angular.js directives) that share the same suffix?

Imagine you have three modal tags that you want to style similarly:

1. <a-modal>
2. <b-modal>
3. <c-modal>

Is there a selector that can be applied to all three without needing them to have a common attribute?

// Attempt with wildcard - does not work
[*-modal] {
  //style...
}

// Would work with attributes:
div[modal="true"] {
  //style...
}

Answer №1

If you're working with Angular directives, consider utilizing class names instead of tag names to target your directives using wildcard CSS selectors:

HTML

<div class="custom-modal"></div>

CSS

[class*="-modal"] {}

Angular

restrict: 'C'


Alternatively, it's advisable to assign a common CSS class for all of them.

Answer №2

It should be as follows:

a-modal, b-modal, c-modal {
  …
}

To simplify a large number of custom HTML tags and avoid lengthy comma-separated CSS selectors, consider using <modal type="a">, etc. along with defining styles for modal { ... }.

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

The Bootstrap modal is not properly clearing all attribute properties when it is hidden

Alrighty, so I've got this modal set up: <div id="modal-container" class="modal fade" tabindex="-1" role="dialog"> <div class="modal-dialog" role="document"> <div class="modal-content center-block" style="displ ...

Code not running properly after activating webpack watch

My AngularJS (1.6) app is built using webpack 3.10. The entry file, Application.ts, sets up the module, runs it, and then boots it to the document. Initially, everything works perfectly after the first build. However, when I make a change, let webpack wat ...

Adding a default option to my AngularJS select box

React const SnazzyContext = React.createContext(); function App() { return ( <SnazzyContext.Provider value={getList()}> <MenuSideController /> </SnazzyContext.Provider> ); } function getList() { // Function to fetch ...

Execute the Angular filter again when there is a change in the scope

I am currently working on an application where Users have the ability to switch between kilometers and miles for unit distances. To handle this, I created a custom filter that converts the distances accordingly: app.filter('distance', function() ...

Struggling with creating a fluid/elastic/liquid layout in HTML. Can someone please assist me with this

I've been attempting to incorporate a fluid layout on my friend's website, but unfortunately, it doesn't seem to be functioning properly. The page is quite simple, with just a slider on it. Could you please take a look at it and let me know ...

Utilizing Angular's $locationProvider in conjunction with ASP.NET MVC routing

Currently, I am managing routing in ASP.NET MVC using the RouteCollection class. However, my front end is built with Angular and there are instances where I need to update the URL using Angular's $location service while also supporting HTML5. To achie ...

Efficient utilization of the bootstrap form-group for optimal responsiveness

I've encountered an issue with the form-group class in Bootstrap. You can view the problem on this link. After analyzing the problem, I found that when viewing the code on a small or medium-sized device, the space between "Statut" and "Etat" appears ...

What are some ways to utilize the $compile function in AngularJS

I attempted to include a template html using an angular controller. After researching how to utilize $compile, I implemented it but unfortunately it failed: CustomersCtrl.$inject = ['$scope', '$http', '$location', '$mo ...

Focusing on the initial element following CSS prioritization

Check out this codepen link: http://codepen.io/muji/pen/XpEYzO I am looking to target the first element after it has been sorted using a CSS "order" property and apply another CSS property to it. Is there a way to use jQuery or any other method to identi ...

Is there a way to set up an automatic pop-up for this?

Experience this code function AutoPopup() { setTimeout(function () { document.getElementById('ac-wrapper').style.display = "block"; }, 5000); } #ac-wrapper { position: fixed; top: 0; left: 0; width: 100%; height: 100%; back ...

Troubleshooting a web browser component within a Firefox add-on

I am in the process of developing a Firefox extension that includes a panel for users to interact with the DOM of any webpage. I want to incorporate existing web components that I have already created, which are constructed using various libraries such as ...

Two-column layout with consistent height vertically, but varying heights on individual rows

By using JavaScript, I am able to ensure that two columns have equal height. The left column contains user input which can vary in length, causing some columns to have more content than others. My current issue is that there are multiple rows instead of ju ...

Intelligent search feature for table data with the ability to submit

Utilizing smart-table, I fetched a dataset from my API and implemented the st-search property to filter multiple parameters. However, I prefer not to update the table query every time the input is changed. I would rather use a submit button to reduce the ...

Tips for organizing ng-repeat information according to a condition of true or false

Apologies if this question has already been addressed, but I have not been able to find a solution. I am attempting to organize an ng-repeat based on the selection of radio buttons, but I am struggling with hiding and showing items within the ng-repeat. ...

What can I do to prevent the text from covering the icon?

My dilemma involves an HTML input alongside a Font Awesome icon. I'm striving to find a way to avoid restricting the amount of text a user can input while ensuring that the text doesn't overlap with .fa-comment-o. Any surplus text should simply b ...

Ways to adjust Safari printing margins using CSS to achieve borderless printing

I am struggling to eliminate margins when printing a webpage to PDF in Safari. Despite setting the page size to 'A4 borderless' in the print dialogue, Safari on OSX continues to add extra margins around my HTML. Enabling 'print backgrounds&a ...

Bootstrap 4.6 - new feature: flexible vertical pills and sleek horizontal tabs (inactive tab no longer highlighted)

I recently implemented Bootstrap 4.6 into my project. The page I am working on includes both vertical pills and horizontal tabs. While the vertical pills are displaying correctly, I have encountered an issue with the styling of the horizontal tabs when th ...

Adjustable div height: reduce until reaching a certain point and then begin expanding once more

Incorporating a hero section to display content is my current approach. The design adapts responsively utilizing the padding-bottom percentage strategy, along with an inner container that is absolutely positioned for central alignment of the content. The ...

How can you update the options within a select tag depending on the selected index of another select tag using AngularJS?

Consider the following code snippet: $scope.letters = ['A', 'B', 'C', 'D']; $scope.numbers = [[0, 1, 2, 3], [4, 5, 6, 7], [8, 9, 10, 11], [12, 13, 14, 15]]; $scope.selectedLetter = 0; There are two select tags in t ...

bootstrap3 container alignment

I encountered a challenge while attempting to right-align multiple Bootstrap 3 containers in a straightforward manner. Despite my efforts, achieving this proved to be more complex than expected. In essence, I faced an issue where aligning the text box with ...