簡體   English   中英

如何在div右側對齊圖像?

[英]How align Image on right side of div?

我正在制作一個div,因為我想在該div的右邊對齊圖像,並在div的其他剩余自由位置上填充同一圖像的顏色,但圖像未與其正確對齊。 主要問題是我不想在div中使用<img>標記,我想將image用作該div的背景圖像,並且也應該正確對齊。

我的小提琴

代碼:

<div class="inq_parent">
        <div class="inq_header">

        </div>
</div>

.inq_parent
{
    height:560px;
    width:90%;
    background-color:#000;
    margin-left:5%;
}
.inq_header
{
    height:100px;
    width:100%;
    background-color:#333333;
    border-bottom: 1px solid #f2f2f2;
    background-image:url(http://i.stack.imgur.com/x9be2.png);
    background-repeat:no-repeat;
    text-align:right;
}

添加background-position:right;

.inq_header
{
    height:100px;
    width:100%;
    background-color:#333333;
    border-bottom: 1px solid #f2f2f2;
    background-image:url(http://i.stack.imgur.com/x9be2.png);
    background-repeat:no-repeat;
  background-position:right;
    text-align:right;
}

或總之

background:url(http://i.stack.imgur.com/x9be2.png) no-repeat right;

DEMO


更新

.inq_header
{
    height:100px;
    width:100%;
    border-bottom: 1px solid #f2f2f2;
    background:#333333 url(http://i.stack.imgur.com/x9be2.png) no-repeat right;

}

更新了演示

暫無
暫無

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

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