繁体   English   中英

背景图像左对齐

[英]Background image aligned left

假设我在这段代码中有一个名为“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显示在ap和@jimmy的左侧以显示图像背景。
这是一个示例图片

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

背景位置:左中心;

要么

background-position:0 0;

然后使用padding将链接放到作者:

padding-left:15px;

你需要添加

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

到.author类

希望这可以帮助!

你需要任何小提琴链接来展示这个吗?

只需使用它

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

暂无
暂无

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

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