html - 如何用图像填充整个标题

标签 html css

我有一个 Bootstrap header ,我想将图像设置为背景。我做到了,但图像没有覆盖标题的整个宽度,它到达某个点,然后像这样重复自己: header 当我应用 css 规则 no-repeat 时,它只是剪切图片并且它没有填满 jumbotron div 的整个宽度,我该怎么做才能使整个图像完全延伸到 div 的末尾,这是我的 html :

<div class="jumbotron">
    <div class="placeholder"></div>
    </div>
    <div class="container">
            <h2>Add a new Animal</h2>
    <div class="form-group">
    Species: <input type="text" id="species" class="form-control">
    Name: <input type="text" id="name" class="form-control" >
    Age: <input type="text" id="age" class="form-control">
    Last Fed: <input type="date" id="last-fed" class="form-control">
    Last Shed: <input type="date" id="last-shed" class="form-control">
    Addition Info: <textarea class="form-control"></textarea>
    <button id="btnCreate" class="btn btn-primary">Create</button>
    </div>
    <ul id="animals"></ul>
    <h3>View Current Animals</h3>
    <button id="btnLoad" class="btn btn-info">Load Animals</button>
    </div>
    </div>

和我的CSS:

button:hover {
    cursor: pointer;
}

.jumbotron {
    background: url('./../images/Header.jpg') ;
    height: 300px;

}

最佳答案

你可以试试这个

.jumbotron {
    background: url('./../images/Header.jpg') ;
    backgound-size: cover;
    height: 300px;
    backgroud-position: center center;

}

如果没有,你得看看这个链接https://www.w3schools.com/css/css3_object-fit.asp

祝你好运

关于html - 如何用图像填充整个标题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52914311/

相关文章:

jquery - 添加 a.link 到 jquery .css

php - 很简单的mod_rewrite问题

javascript - 如何获取选择器使用 find() 函数获得的 radio 输入值

python - 如何使用 BeautifulSoup 从 HTML 段落中提取内容?

html - 样式化组件,带有 gatsby-link anchor 标记 css 着色

javascript - 过渡 div 的高度以适合其内容

html - css + html : relative percentages?(媒体查询)

php - 提交到 SQL 后更新文本区域

html - 多行内联 block 变成了一个 block 并破坏了我漂亮的引用效果

css - 无法更改 bootstrap-datepicker 的颜色