背景图像左对齐

时间:2014-03-25 12:48:16

标签: html css

让我们说我有一个名为“作者”的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显示在@jimmy的p和左侧以显示图像背景。
this is an example picture

3 个答案:

答案 0 :(得分:2)

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

  

background-position:left center;

  

background-position:0 0;

然后使用填充来将链接发送给作者:

  

padding-left:15px;

答案 1 :(得分:0)

你需要添加

background-position: 0 0; padding-left: 10px /*this should be equal to image width*/

到.author class

希望这有帮助!

你需要任何小提琴链接才能显示出来吗?

答案 2 :(得分:0)

只需使用此

即可
 `background:url("img/user91.png") no-repeat right 0px; `
相关问题