css-specificity

CSS class priorities

為{幸葍}努か 提交于 2019-12-28 11:54:13
问题 I have a question about the priority of CSS classes after encountering a problem today. The situation is as follows: I have an unordered list which has a class associated with it. The LI tags have some styles defined too. I want to change the styling of the LI s after a click (via an added "selected" class), but the added class's styles are never applied. Is this normal behavior or should this code work? CSS: .dynamicList { list-style: none; } .dynamicList li { display: block; width: 400px;

How does CSS specificity decide which styles to apply?

百般思念 提交于 2019-12-28 04:25:06
问题 How does CSS determine when to apply one style over another? I have been through the W3 CSS3 selectors document a few times, and that has helped me understand how to better use CSS selectors in jQuery, but it has not really helped me understand when one CSS rule will be applied over another. I have the following the HTML: <div class='item'> <a>Link 1</a> <a class='special'>Link 2</a> </div> I have the following CSS: .item a { text-decoration: none; color: black; font-weight: bold; font-size:

Overriding CSS properties for a specific html element

拈花ヽ惹草 提交于 2019-12-28 02:13:26
问题 I have the following: <section class="main_section"> <article> ... </article> </section> In my stylesheet I have: .main_section article { background-color:#fff; /* ... */ } The article is styled, and I am happy about it. Now, for a single instance of article , I want to do the following: <section class="main_section"> <article class="special-bg"> ... </article> </section> Which I have defined: .special-bg { background-color: #276a7f; } But the class is not setting the background-color. It

Determining CSS Specificity Score [duplicate]

巧了我就是萌 提交于 2019-12-25 19:39:14
问题 This question already has answers here : How are the points in CSS specificity calculated (7 answers) Closed 2 years ago . How do I calculate the specificity score for these declaration blocks: body div main section div ul li p strong span a {} Specificity = 1*11=11 and, .someClass {} Specificity = 10 * 1 = 10 So, will the first one win? 回答1: W3C specification states: A selector's specificity is calculated as follows: count the number of ID selectors in the selector (= a) count the number of

JavaFX Tableview make specific cells colored

只愿长相守 提交于 2019-12-25 09:01:07
问题 TableColumn tc = new TableColumn(); tc.getStyleClass.add(".style in css file") i set up the tablecolumn with css file. and i want to make each cell has different backgrounds. is there any way to do it? tableColumn row 1 bakcground color = green, row2 = red, row3 = blue....etc 回答1: You have to use setRowFactory for your TableView and change row style. A little example there: tableView.setRowFactory(new Callback<TableView<Data_type>, TableRow<Data_type>>(){ //There can define some colors. int

Flexbox seems to be ignoring CSS specificity

别说谁变了你拦得住时间么 提交于 2019-12-23 16:32:26
问题 I am attempting to use Flex-By-Default in the same manner as Facebook's CSS layout project. I am having some trouble when it comes to overriding the styles for display: inline-flex elements. Per this jsfiddle: The HTML, with two '.test-me' divs: <body> <h1>TEST</h1> <div class="test-me"> I'm correctly displayed as inline-flex </div> <div> <div class="test-me"> 'Styles' shows inline-flex, but 'Computed' shows flex </div> </div> </body> Here is the styling: .test-me { display: inline-flex;

CSS Specificity - Defining Classes & IDs

半腔热情 提交于 2019-12-23 01:36:14
问题 I've been reading up on specificity and, quite frankly, I'm surprised that I didn't know about this properly before, since I've witnessed the very issues that specificity can give if CSS is declared in the wrong manner. So, I've been doing a little research on the subject, and I now understand the rule for calculating specificity. However, during my findings, I've been left with three questions which I was hoping you guys could help me out with. Firstly, when relating to CSS specificity, I've

CSS rules output by SASS mixin being ignored

不想你离开。 提交于 2019-12-20 06:51:08
问题 A SASS mixin which produces some CSS rules is being ignored. Chrome Dev Tools is showing the rules registered but crossed out and I cannot figure out why. I initially thought there was a conflict of specificity but there are no conflicting rules. Here is the SASS: span.icon { display: inline-block; background-image: url('images/sprite.png'); background-repeat: no-repeat; &.telephone { @include sprite('19px', '25px', '-300px 0'); } } Here is the mixin: @mixin sprite($width, $height, $bg

How to style :root without !important using proper specificity

陌路散爱 提交于 2019-12-20 03:17:47
问题 Inside a Custom Element because border-color is set on the parent page, I can not make border-color work without resorting to !important :host([player="O"]) { color: var(--color2); border-color: var(--color2) !important; } The selector works fine, the color is set, so it is a Specificity issue Question: Is it possible without !important ? Working snipppet: window.customElements.define('game-toes', class extends HTMLElement { constructor() { super(); let shadowRoot = this.attachShadow({ mode:

Why is the # selector of lesser specificity than anything?

一曲冷凌霜 提交于 2019-12-18 15:19:06
问题 Big bold caps-lock TL;DR: I KNOW HOW SELECTOR SPECIFICITY IS DETERMINED, I THINK IT USES FLAWED ASSUMPTIONS AND I CAN BACK MY IRRITATIONS UP WITH VALID SET THEORY RELATIONS, PLEASE DO NOT RESPOND EXPLAINING W3 CALCULATION RULES FOR SPECIFICITY, PLEASE READ THE QUESTION <- read that. This has bothered me for some time, when I write a style for some HTML that would be similar to below: ... <div id="outer"> <span id="inner"></span> <span></span> ... </div> ... Why would specificity rules make