我知道这个问题有很多相关的提问,但对我来说没有一种方法是有效的。
我需要把我的PanelGrid水平居中对齐。
这是我的panelgrid
<p:panelGrid styleClass="panelGridCenter">
我的 CSS 代码:
.panelGridCenter td,.panelGridCenter tr {
text-align: center;
}
它只是将内容居中对齐,但不包括panelGrid
我知道这个问题有很多相关的提问,但对我来说没有一种方法是有效的。
我需要把我的PanelGrid水平居中对齐。
这是我的panelgrid
<p:panelGrid styleClass="panelGridCenter">
我的 CSS 代码:
.panelGridCenter td,.panelGridCenter tr {
text-align: center;
}
它只是将内容居中对齐,但不包括panelGrid
JSF的<p:panelGrid>
组件呈现了一个HTML<table>
元素,它默认是块级元素。要使块级元素本身居中,应将其水平边距设置为auto
,而不是尝试将其内联内容居中。
.panelGridCenter {
margin: 0 auto;
}
.rightAlign{
margin-left: auto;
}
<h3 id="signInTitle" class="first">Sign in - FIXME - i18n</h3>
<form id="loginFormOld" (ngSubmit)="onLoginFormSubmit()">
<!-- (a) Start a grid system-->
<div class="ui-g ui-fluid">
<!-- (b) Eat the first four cells of the grid -->
<div class="ui-g-12 ui-md-4"></div>
<!-- (c) In the center location of the grid put in the Login form -->
<div class="ui-g-12 ui-md-4">
<div class="ui-inputgroup">
<span class="ui-inputgroup-addon"><i class="fa fa-user"></i></span>
<input id="emailInput" pInputText type="email" placeholder="Email" [(ngModel)]="eMail" name="eMail">
</div>
<div class="ui-inputgroup">
<span class="ui-inputgroup-addon"><i class="fa fa-key" aria-hidden="true"></i></span>
<input id="passwordInput" pInputText type="password" class="form-control" placeholder="Password" [(ngModel)]="password" name="password">
</div>
</div>
<!-- (d) Eat the rest of the first row of the grid without setting any contents -->
<div class="ui-g-12 ui-md-4"></div>
<!-- (e) Start the second row and eat the first four cells -->
<div class="ui-g-12 ui-md-4"></div>
<!-- (f) Position a form submit button on the fifth cell -->
<div class="ui-g-12 ui-md-1">
<button id="loginSubmit" pButton type="submit" label="Submit"></button>
</div>
</div>
</form>
p:panelGrid layout="grid"
(PF 6.1文档第365页)。除此之外,如果“相对应”的JSF组件的优势过于有限,我会尝试使用纯HTML。 - Kukeltjetable
、tr
和td
的CSS(在我看来非常容易),所以你甚至可以使现有组件“响应式”...我做到了。最困难的事情是你需要为盲人和聋人添加所有新的“属性”。这并不是说这样做不好,但这有点重复劳动。干杯! - Kukeltje
.rightAlign
?在<h:body>
上吗? - Kukeltje