2

I'd like to understand how to override default components such as tab menu ONCE throughout the whole application. The way I normally do this (in Chrome) is to inspect the component, get the class and add it to the css, ensuring that the naming convention is consistent with the PF documentation. In the below example I try to INSPECT the tab element from the browser.

enter image description here

After hovering around to the right area I tried a couple of possible CSS variants to change the background color and the default tab widths:

.ui-tabs-selected, .ui-state-active {
width: 20%;
background-color: #ff0000;
}

.ui-tabs-nav {
background-color: #ff0000;
}

The first css option seemed to change the width but not the background color. The second didn't do anything. Instead of trial and error, I want to understand how to get the right class values from doing a page Inspect in the browser console?

1) For changing the default styling of PF components, is it correct to use INSPECT in the browser console and to then add the generated component class names into your css?

2) How do you know what class name you are looking for? What is the correct syntax that defines a correctly generated class name?

A couple of questions here helped me out but didn't answer the above:

The answer to this question provided a clue to use

#tabView .ui-tabs-panel
{
padding: 0;   
}

I couldn't figure out how that was decided to as the right reference and the reference didn't work in any case.

The below questions helped to explain that the semi colon is a class pseudo selector and must be escaped if using explicit class references, which I assume doesn't apply to customizing components throughout the whole application ONCE?

Primefaces CSS overwrite single component

This was the most helpful for explaining the underlying theory:

How to use JSF generated HTML element ID with colon ":" in CSS selectors?

This tackles how to use style classes to customize individual components but doesn't go into detail of how to inspect a web page and extract the component specific class to customize that component throughout the whole application:

How to Override Primefaces default CSS?

Styleclasses isn't the option I"m looking for. I'm looking for a generic, application wide customization

These other were great for understanding CSS specificity and inheritance but I'm still not able to apply these theories to my concrete problem:

What are valid values for the id attribute in HTML?

Primefaces override CSS correctly

http://www.w3.org/TR/CSS2/cascade.html

I didn't see any answer in those and would appreciate any guidance on the above questions. Thank you!

Community
  • 1
  • 1
jay tai
  • 217
  • 1
  • 7
  • 25
  • 1
    All the links you posted contain all relevant info. Besides the correct selectors. For those: learn css (and css specificity). Adding a styleClass to the `h:body` of your template and using that in your selectors might already help – Kukeltje Jan 10 '16 at 17:23
  • I'll re-read them and others again, though I didn't see any specifics about how to properly use the page inspect for PF components. If you're saying it's all about knowing css after which I"ll be able to easily apply this to PF that's useful advice. I was really asking if there's any points to note specific to customizing in PF. styeClass in template is excellent. I'l give it a try though I'd still prefer understanding HOW to correctly refer to PF component classes in css. Many thanks – jay tai Jan 10 '16 at 17:45
  • 1
    Refering to PF 'components' (their client-side html counterpart at least) is just like referring to any html element, since client-side it all is html and css works client-side. Just take all the things of css-specificity into account. Read the modev article referred to in several posts you linked to – Kukeltje Jan 10 '16 at 18:00
  • 1
    http://stackoverflow.com/q/8768317? – BalusC Jan 11 '16 at 06:41

0 Answers0