How to remove border from specific PrimeFaces p:panelGrid?

CssJsfPrimefacesFacelets

Css Problem Overview


I have difficulty in removing border from a specific PrimeFaces <p:panelGrid>.

<p:panelGrid styleClass="companyHeaderGrid">
    <p:row>
        <p:column>
            Some tags
        </p:column>
        <p:column>
            Some tags
        </p:column>
    </p:row>
</p:panelGrid>

I have been able to remove border from the cells with:

.companyHeaderGrid td {
    border: none;
}

But

.companyHeaderGrid {
    border: none;
}

Does not work.

Css Solutions


Solution 1 - Css

The border is been set on the generated tr and td elements, not on the table. So, this should do:

.companyHeaderGrid.ui-panelgrid>*>tr,
.companyHeaderGrid.ui-panelgrid .ui-panelgrid-cell {
    border: none;
}

How I found it? Just check the generated HTML output and all CSS style rules in the webdeveloper toolset of Chrome (rightclick, Inspect Element or press F12). Firebug and IE9 have a similar toolset. As to the confusion, just keep in mind that JSF/Facelets ultimately generates HTML and that CSS only applies on the HTML markup, not on the JSF source code. So to apply/finetune CSS you need to look in the client (webbrowser) side instead.

enter image description here

See also:

If you're still on PrimeFaces 4 or older, use below instead:

.companyHeaderGrid.ui-panelgrid>*>tr,
.companyHeaderGrid.ui-panelgrid>*>tr>td {
    border: none;
}

Solution 2 - Css

I am using Primefaces 6.0 and in order to remove borders from my panel grid i use this style class "ui-noborder" as follow:

<p:panelGrid columns="3" styleClass="ui-noborder">
   <!--panel grid contents -->
</p:panelGrid>

It uses a css file named "components" in primefaces lib

Solution 3 - Css

This worked for me:

.ui-panelgrid td, .ui-panelgrid tr
{
border-style: none !important
}

Solution 4 - Css

If BalusC answer doesn't work try this:

.companyHeaderGrid td {
     border-style: hidden !important;
}

Solution 5 - Css

If you find a line in between the columns then use the below code,

.panelNoBorder, .panelNoBorder tr, .panelNoBorder td{
border: hidden;
border-color: white;
}

I checked this with Primefaces 5.1

<h:head>
     <title>Login Page</title>    
     <h:outputStylesheet library="css" name="common.css"/>
</h:head> 

<p:panelGrid id="loginPanel" columns="3" styleClass="panelNoBorder">
<p:outputLabel value="Username"/> <p:inputText id="loginTextUsername"/>
<p:outputLabel value="Password"/> <p:password id="loginPassword"/>
<p:commandButton id="loginButtonLogin" value="Login"/> <p:commandButton id="loginButtonClear" value="Clear"/>
</p:panelGrid>  

Solution 6 - Css

Nowdays, Primefaces 5.x have a attribute in panelGrid named "columnClasses".

.no-border {
    border-style: hidden !important ; /* or none */
}

So, to a panelGrid with 2 columns, repeat two times the css class.

<p:panelGrid columns="2" columnClasses="no-border, no-border">

To other elements, the ugly " !important " is not necessary, but to the border just with it work fine to me.

Solution 7 - Css

Try

<p:panelGrid styleClass="ui-noborder">

Solution 8 - Css

Just add those lines on your custom css mycss.css

table tbody .ui-widget-content {
    background: none repeat scroll 0 0 #FFFFFF;
    border: 0 solid #FFFFFF;
    color: #333333;
}

Solution 9 - Css

As mentioned by BalusC, the border is set by PrimeFaces on the generated tr and td elements, not on the table. However when trying with PrimeFaces version 5, it looks like there is a more specific match from the PrimeFaces CSS .ui-panelgrid .ui-panelgrid-cell > solid which still result in black borders being shown when appyling the style suggested.

Try using following style in order to overide the Primefaces one without using the !important declaration:

.companyHeaderGrid tr, .companyHeaderGrid td.ui-panelgrid-cell {
    border: none;
}

As mention make sure your CSS is loaded after the PrimeFaces one.

Solution 10 - Css

If you just want something more simple, you can just change:

<p:panelGrid >
  
</p:panelGrid>

to:

<h:panelGrid border="0">

</h:panelGrid>

That's worked fine for me

Solution 11 - Css

for me only the following code works

.noBorder tr {
border-width: 0 ;
}
.ui-panelgrid td{
	border-width: 0
}

<p:panelGrid id="userFormFields" columns="2" styleClass="noBorder" >
</p:panelGrid>

Solution 12 - Css

For the traditional as well as all the modern themes to have no border, apply the following;

<!--No Border on PanelGrid-->
    <h:outputStylesheet>
        .ui-panelgrid, .ui-panelgrid td, .ui-panelgrid tr, .ui-panelgrid tbody tr td
        {
            border: none !important;
            border-style: none !important;
            border-width: 0px !important;
        }
    </h:outputStylesheet>

Solution 13 - Css

I placed the panelgrid inside datatable, and hence my working solution is

.ui-datatable-scrollable-body .myStyleClass tbody td{border:none;}

for

<h:panelGrid  styleClass="myStyleClass" >...</h:panelGrid>

Solution 14 - Css

In primefaces, theme.css will have below code, just we need to specify styleClass as 'ui-panelgrid-blank'. So this will remove the border for panelGrid component.

.ui-panelgrid.ui-panelgrid-blank {
  border: 0 none;
  background: none;
}

<p:panelGrid columns="2" layout="grid" styleClass="ui-panelgrid-blank">
</p:panelGrid>

Solution 15 - Css

Please try this too

.ui-panelgrid tr, .ui-panelgrid td {
border:0 !important;
}
 

Solution 16 - Css

Use below style modification to remove border for Primefaces radio button

.ui-selectoneradio td, .ui-selectoneradio tr
{
    border-style: none !important
}

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionEleeistView Question on Stackoverflow
Solution 1 - CssBalusCView Answer on Stackoverflow
Solution 2 - CssMr.QView Answer on Stackoverflow
Solution 3 - CssMohammed PashaView Answer on Stackoverflow
Solution 4 - CssPaul WasilewskiView Answer on Stackoverflow
Solution 5 - CssAjeeshView Answer on Stackoverflow
Solution 6 - CssKanjaranaView Answer on Stackoverflow
Solution 7 - Cssspyder manView Answer on Stackoverflow
Solution 8 - CssMarouane AfroukhView Answer on Stackoverflow
Solution 9 - CssCodeNotFoundView Answer on Stackoverflow
Solution 10 - CssEdson CezarView Answer on Stackoverflow
Solution 11 - CssjrabasilioView Answer on Stackoverflow
Solution 12 - CssKoekieboxView Answer on Stackoverflow
Solution 13 - CssTeelaView Answer on Stackoverflow
Solution 14 - CssArunView Answer on Stackoverflow
Solution 15 - Csstechy360View Answer on Stackoverflow
Solution 16 - CssGanesh KumarView Answer on Stackoverflow