簡體   English   中英

HTML CSS圖像對齊

[英]html css image alignment

我有一個關於CSS圖像對齊的問題。 例如,我創建了一個CSS類,如下所示:

.link {
 background: url("images/image1.gif") scroll right;
}

下面是標記

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
        <title>Untitled Document</title>
        <p class="link">This is a link</p>
    </head>
    <body>
    </body>
</html>

當我在瀏覽器中簽到時,我在文字上得到了圖像。 我要的意思是我的意思

這是一個鏈接(這是我希望圖像出現的位置)

嘗試

.link {
  background: url("images/image1.gif") top right no-repeat;
  padding-right: 32px; /* or the width of your image */
}

不應該是位置正確而不是向右滾動嗎? 您也可以給鏈接文本一些填充以清除背景圖片。

不知道我是否理解正確,但是假設您嘗試在文本結束后立即顯示圖像,則可以嘗試如下操作:

.link {
       background: url("images/image1.gif") scroll right;
       padding-right: 20px; /* adjust to fit nicely with your design */
}

希望能幫助到你 :)

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM