Html 背景图像左对齐

Html 背景图像左对齐,html,css,Html,Css,假设我有一个名为“author”的css类,如下代码所示: .author { background:url('img/user91.png'); background-size:10px 10px; background-repeat:no-repeat; color:#62c6ff; bottom: 0; font-family: sans-serif; text-decoration: none; text-transform

假设我有一个名为“author”的css类,如下代码所示:

.author {
    background:url('img/user91.png');
    background-size:10px 10px;
    background-repeat:no-repeat;
    color:#62c6ff;
    bottom: 0;
    font-family: sans-serif;
    text-decoration: none;
    text-transform: lowercase;
    font-size: 9px;
    margin-left: 20px;
    margin-top: 70px;
}
和html:

<p class="author"><a href="#">@jimmy</a></p>

我希望@jimmy显示在p中,并在@jimmy的左侧显示图像背景
您需要添加

background-position: 0 0; padding-left: 10px /*this should be equal to image width*/
到。作者类

希望这有帮助


您是否需要任何小提琴链接来显示此图像?

您应该使用背景位置将图像放置在左侧:

背景位置:左中

背景位置:0

然后使用填充来放置指向作者的链接:

左侧填充:15px

简单地使用这个

 `background:url("img/user91.png") no-repeat right 0px; `