Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to align <h:panelGrid> itself NOT items in a center?

Tags:

html

css

jsf

When i use this snippet code

<h:panelGrid id="myGrid" columns="1"
rendered="#{myBean.showResults}" width="50%"
border="1" style="text-align: center;">  

The items of the panelGrid will be centralized
BUT
I want to centralize h:panelGrid itself in the center of the my XHTML page
Like this HTML code

<table id="myGrid" border="1" align="center">
like image 442
ahmednabil88 Avatar asked Feb 18 '23 23:02

ahmednabil88


1 Answers

Provided that it has a known width, give it a left and right margin of auto. This way it will center itself relative to the parent block element.

<h:panelGrid ... style="margin: 0 auto;">

See also:

  • Center a div in CSS
like image 107
BalusC Avatar answered Feb 20 '23 13:02

BalusC