[英]How to add background image and icon to a JSF button?
I am using JSF 2.0 我正在使用JSF 2.0
I am able to add Background image to the JSF button but am not able to add icon to the button. 我能够将背景图像添加到JSF按钮,但不能将图标添加到按钮。
My Requirement is:- JSF button with Background image and a Icon 我的要求是:-带有背景图片和图标的JSF按钮
Following code am using to add background. 以下代码用于添加背景。
<!-- Discard button-->
<h:commandButton action="discard" style="background-image: url('..\\Images\\leftMenuActiveBg.png');width: 150px;height: 30px;color: white;border-color: white;font-size: 15px; " value="#{message.discard}">
<rich:componentControl target="popup" operation="show" />
</h:commandButton>
Can somebody help me in adding a icon to the button too please. 有人也可以帮我在按钮上添加图标吗?
I am updating a image for better Explainanation as what I want to achieve and I what I have achieved till now with above code. 我正在更新映像,以更好地解释我想要实现的目标,以及我到目前为止通过以上代码所实现的目标。
So you want a button with two background images? 因此,您想要一个带有两个背景图像的按钮吗? That's not possible on a single HTML element. 在单个HTML元素上是不可能的。 The <h:commandButton>
generates an single HTML <input type="submit">
element, while you basically need a <button type="submit" class="background"><span class="icon">
instead. <h:commandButton>
生成一个HTML <input type="submit">
元素,而您基本上需要一个<button type="submit" class="background"><span class="icon">
来代替。 You'd need to create a custom component which generates exactly that HTML, or to adopt a 3rd party component librarty which has such a component in its set, such as PrimeFaces . 您需要创建一个完全生成HTML的自定义组件,或者采用第三方组件librarty,该组件在其集合中具有此类组件,例如PrimeFaces 。 See also the <p:commandButton>
showcase . 另请参见<p:commandButton>
展示柜 。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.