如何将文本和图像放在同一行?

Erç*_*ğlu 1 html css html5 css3

如何将文本和图像放在同一行中,例如居中于图像?我尝试了一些方法,比如vertical-align:middle; 显示:内联; 但不工作......我的错误在哪里?

现在:

在此输入图像描述

我的css代码:

<style>
    .entryDetailX {
        float: right;
        background: #2B587A;
        -moz-border-radius-topleft: 8px;
        -webkit-border-top-left-radius: 8px;
        -moz-border-radius-bottomright: 8px;
        -webkit-border-bottom-right-radius: 8px;
        font-weight: bold;
        color: #FFF;
        padding: 6px;
    }
    .date {
        float: right;
        font-size: 9px;
        padding-top: 1px;
        background: url(/content/themes/mavi/img/custom/icon_time16x16.png) top left no-repeat;
        padding-left: 20px;
        margin-right: 10px;
    }
    .nick {
        float: right;
        margin-right: 20px;
        color: #cc9900;
        background: url(/content/themes/mavi/img/custom/icon_user16x16.png) top left no-repeat;
        padding-left: 20px;
    }
</style>
Run Code Online (Sandbox Code Playgroud)

HTML:

<div class="entryDetailX">
    <span class="date">18.01.2011 00:50:55</span>
    <a class="nick">phantasm</a>
</div>
Run Code Online (Sandbox Code Playgroud)

谢谢

小智 6

你只需要添加

 background-position:left center;
Run Code Online (Sandbox Code Playgroud)

检查小提琴