![](/img/trans.png)
[英]How do you stick an image to the left side of a div when upon scroll, it moves with the div?
[英]How do you Add an image to the left side of a div
我想讓圖像出現在div的左側(垂直居中)。 怎么做?
這是我的代碼。 (圖像在每個角處看起來都非常小。我嘗試了背景url(../ images / error24x24.png),但沒有重復;但這也不行。(圖像已加載,但看上去很時髦)
.formValidation {
background-color:rgb(71,89,32);
color:white;
font-weight:bold;
padding:10px;
-moz-border-radius:6px;
border-radius:6px;
-webkit-border-image: url(../images/error24x24.png);
border-image: url(../images/error24x24.png);
}
<div class="formValidation">
Please enter a category.
</div>
編輯:我的最終CSS:
.formValidation {
background-color:rgb(52,31,36);
color:white;
font-weight:bold;
padding:10px 10px 10px 35px;
-moz-border-radius:15px;
border-radius:15px;
margin-bottom:10px;
background-image: url(../images/error24x24.png);
background-position:8px center;
background-repeat:no-repeat;
}
使用background-image
和background-position
代替border-image
。
這是一個開始的好地方: http : //coding.smashingmagazine.com/2009/09/02/backgrounds-in-css-everything-you-need-to-know/
檢查MDN以獲取全面的文檔: https : //developer.mozilla.org/en-US/docs/CSS/background
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.