css - How to align contents of <p:panel> vertical-align to center -
in jsf-primefaces webapp having , need vertical-align contents center. how can that?
<p:panel id="businesses_panel" header="#{business.businessname}" styleclass="mini-panel panel-grid tr panel-grid td panel-hover panel-header-title-small"> <div align="center"> <p:panelgrid columns="1"> <div class="component-spacing-top"/> <h:graphicimage alt="#{business.businessname}" value="#{business.logofullpath}" class="small-panel-image" /> <div class="component-spacing-top"/> </p:panelgrid> </div>
<p:panel style="height:500px;position:relative;"/> <p:panelgrid columns="1" styleclass="centered"> <div class="component-spacing-top"/> <h:graphicimage alt="#{business.businessname}" value="#{business.logofullpath}" class="small-panel-image" /> <div class="component-spacing-top"/> </p:panelgrid> </p:panel> height value randomly given not matter, not erase position:relative.
.centered { position: absolute; height: 100px; top: 0; bottom: 0; margin:auto; } for horizontal should add below rules:
left:50%;margin-left:-100px;width:200px; look out, margin-left value -1/2 times of width value.
result:

if width not fixed can try way works on me , aligns center horizontally , vertically @ same time:
<p:panel style="line-height:200px;padding: 5% 0;position: relative;"/> <p:panelgrid columns="1" styleclass="centered"> <div class="component-spacing-top"/> <h:graphicimage style="vertical-align:middle;" alt="#{business.businessname}" value="#{business.logofullpath}" class="small-panel-image" /> <div class="component-spacing-top"/> </p:panelgrid> </p:panel> note graphicimage has style property well.
.centered { position:relative; height: 100px; margin:0 auto; padding: 10% 0; } result:

even if doesn't work should check link gave inside about. doing there 6 ways , should mix them.
Comments
Post a Comment