css - 将图像命令中的文本居中链接

标签 css jsf commandlink

我有一个 p:commandLink

.button{
    background-image: url(http://www.lefinnois.net/aqua/aqua1.jpg);
    display:inline-block;
    width:150;
    height:50;   
}
<p:commandLink update="media" value="Ok"
    action="#{productView.save}" styleClass="button">
</p:commandLink>

没关系,我有一个图像按钮。

但我希望“确定”文本出现在按钮图像的中间

你的建议是什么,我已经尝试了一些但到目前为止没有回应。

我认为这一定是可能的,如果 jsf 是一个网络编程平台。

已解决

我必须向外部对象添加填充以定位内部对象。

最后的代码:

.button{
        background-image: url(http://www.lefinnois.net/aqua/aqua1.jpg);
        display:inline-block;
        text-align: center;
        padding-top:10px;//you must set it according to the height of image
        width:150;
        height:50;   
    }

最佳答案

将 CSS text-align 属性设置为 center 并将 line-height 设置为与元素高度相同的高度:

text-align: center;
line-height: 50px;

不要忘记修改您的 widthheight 值以包含尺寸。

width: 150px;
height: 50px;

关于css - 将图像命令中的文本居中链接,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8572764/

相关文章:

php - Wordpress 插件(终极成员(member))在更改 wordpress url 后仍然调用 localhost

javascript - 输入 Unresolved 任务

javascript - jQuery ajax,等到 beforeSend 动画结束

java - 查找java应用程序的相对路径

javascript - 单击 h :commandLink causes Uncaught ReferenceError: mojarra is not defined

css - 使用 CSS 更改悬停时的链接不透明度

jsf - PrimeFaces p :autoComplete: Show number of all results

java - p :commandLink action does not fire

css - 使用 p/h :panelGrid columns 内的链接

java - 如何在合并单元格poi java中插入值