简体   繁体   English

JSF包装 <h:outputLabel> 文本wrt到下一行的起始索引

[英]JSF wrapping the <h:outputLabel> text w.r.t to starting index of the its own in next line

I have a an outputlable <h:outputLabel id="label1" value="Project Name"/> .Next to that I have another <h:outputLabel id="label2" value="#{XXBean.details.projectName}"/> 我有一个outputlable <h:outputLabel id="label1" value="Project Name"/> outputLabel <h:outputLabel id="label1" value="Project Name"/><h:outputLabel id="label2" value="#{XXBean.details.projectName}"/>还有另一个<h:outputLabel id="label2" value="#{XXBean.details.projectName}"/>
Both labes are located inside a <p:fieldset> 两个标签都位于<p:fieldset>
label2 will get rendered based on the value in bean. label2将根据bean中的值进行渲染。 label2 is getting wrapped in the next line but the wrapped text should start from the starting index of the label2 not from starting index of label1. label2正在换行,但换行后的文本应从label2的起始索引开始,而不是从label1的起始索引开始。

I tried <h:outputLabel style="white-space: pre;word-wrap: break-word;" /> 我尝试了<h:outputLabel style="white-space: pre;word-wrap: break-word;" /> <h:outputLabel style="white-space: pre;word-wrap: break-word;" />
but it shows the label2 in a straight line and its extending the size of the fieldset. 但它显示的是label2的直线,并且其扩展了字段集的大小。 And its not wrapping it as per the expected results given below. 并且它没有按照下面给出的预期结果包装它。

Actual result I am getting : 

 label1:labellabel2label2label2label2label2label2label2label2label2
 label2label2label2label2

Expected :

label1:labellabel2label2label2label2label2label2label2label2label2
       label2label2label2label2

Please advise me to get the Expected output. 请建议我得到预期的输出。

the first label has a fix width (its only "Project Name" value) and the second one depend on the width from labels wrapper (eg fieldset). 第一个标签具有固定宽度(仅其“项目名称”值),第二个标签取决于标签包装器的宽度(例如,字段集)。

#label1{
    display: inline-block;
    vertical-align: top;
}
#label2{
    display: inline-block;
    width: 66%;
}

Set correct label2 width depends from the wrapper. 设置正确的label2宽度取决于包装器。

Alternative: Display labels as a table cell. 替代方法:将标签显示为表格单元格。

#label1{
    display: table-cell;
    vertical-align: top;
}
#label2{
    display: table-cell;
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM