簡體   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