简体   繁体   English

如何将背景图像设置为全长并使文本居中对齐?

[英]How to set background image to full length and make text align center?

My header-banner is set to width 100% but its not covering everything on the top it looks like its 70% and text is not setting to center, When i inspect element in chrome it shows 100% width but in actual display it does not. 我的标题横幅设置为宽度100%,但它没有覆盖顶部的所有内容,看起来像是70%,文本未设置为居中,当我检查镀铬元素时,其显示为100%宽度,但在实际显示中却没有。 How can i fix this issue ? 我该如何解决这个问题?

main.html main.html

<div class="row">
    <div class="col-md-12">
        <div class="header-banner">
            <h1>Server</h1>
        </div>
    </div>
</div>

main.css main.css

.header-banner {
    background:url('../img/header_master.jpg');
    width:100%;
    min-height:70px;
    background-repeat: no-repeat;
    text-align: center;
}

Try It: 试试吧:

.header-banner {
        background:url('../img/header_master.jpg');
        width:100%;
        min-height:70px;
        background-repeat: no-repeat;
        text-align: center;
        background-size: cover;
    }

Bootstrap rows have a margin associated with them. 引导程序行具有与之关联的边距。 So when using bootstrap rows there will always be a margin unless you remove that in CSS. 因此,在使用引导程序行时,除非在CSS中将其删除,否则始终会有一个空白。

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

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