简体   繁体   English

工具提示背景颜色更改和primefaces中工具提示文本的字体样式

[英]tooltip background color change and font styles of tooltip text in primefaces

I am trying to see some features availability in prime-faces..... I wanted to know if there are any font styles and background color change functionality available in tool-tip in prime-faces... 我试图在prime-faces中看到一些功能可用性......我想知道在prime-faces中工具提示中是否有任何字体样式和背景颜色更改功能...

Please let me know. 请告诉我。

here is the sample code: 这是示例代码:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:f="http://java.sun.com/jsf/core"      
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:p="http://primefaces.org/ui">

    <h:head>
        <title>Tool Tip Customization</title>
    </h:head>
    <h:body>

    <h:panelGrid columns="3" cellpadding="5">  

    <h:outputText value="Focus/Blur: " />  
    <p:inputText id="focus" title="This tooltip is displayed when input gets the focus"/>  
    <p:tooltip for="focus" showEvent="focus" hideEvent="blur" />  

    <h:outputText value="Fade: " />  
    <h:outputLink id="fade" value="#">  
        <h:outputText value="Fade Effect" />  
    </h:outputLink>  
    <p:tooltip for="fade" value="Fade effect is used by default" showEffect="fade" hideEffect="fade" />  

    <h:outputText value="Slide: " />  
    <h:outputLink id="slide" value="#">  
        <h:outputText value="Slide Effect" />  
    </h:outputLink>  
    <p:tooltip for="slide" value="This tooltip uses slide effect for the animation" showEffect="slide" hideEffect="slide" />  

    <h:outputText value="Clip/Explode: " />  
    <h:outputLink id="grow" value="#">  
        <h:outputText value="Clip/Explode Effects" />  
    </h:outputLink>  
    <p:tooltip for="grow" value="This tooltip uses clip/explode effects for the animation" showEffect="clip" hideEffect="explode" />  

    <h:outputText value="Content:  " />  
    <h:outputLink id="lnk" value="#">  
        <h:outputText value="PrimeFaces Users" />  
    </h:outputLink>  
    <p:tooltip for="lnk">  
        <p:graphicImage value="C:\raman\AMAP\POC\primefaces\JSF2.0HelloWorld\WebContent\images\Users.gif" />  
    </p:tooltip>  

</h:panelGrid>  
</h:body>
</html>

If you want to set styles for all tooltips globally you can use class ui-tooltip . 如果要全局设置所有工具提示的样式,可以使用类ui-tooltip For example like this: 例如这样:

.ui-tooltip {
    border: 1px solid #ccc;
    box-shadow: 0 0 10px 0 #ddd;
    -moz-box-shadow: 0 0 10px 0 #ddd;
    -webkit-box-shadow: 0 0 10px 0 #ddd;
    color: #666;
    background: #f8f8f8;
}

As written in PrimeFaces Userʼs Guide: Tooltip has only .ui-tooltip as a style class and is styled with global skinning selectors, see main skinning section for more information. 正如PrimeFaces用户指南中所写:Tooltip只有.ui-tooltip作为样式类,并使用全局蒙皮选择器设置样式,有关详细信息,请参阅主要蒙皮部分。

The Primefaces tooltip component has style and styleClass attributes: Primefaces工具提示组件具有stylestyleClass属性:

Quick example to change font color: 更改字体颜色的快速示例:

<p:tooltip for="slide" value="Text" 
           style="color : red; background-color : yellow"/>  

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

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