html - 如何让 div 背景图像缩放到页面大小?

标签 html css image scale

我正在尝试使 div header 的背景图像缩放到页面大小。这是当前的 CSS:

.Header {
    background-image: url(Images/logo.png);
    height: 160px;
    width: 960px;
    margin-left: auto;
    margin-right: auto;
    margin-top: 20px;
}

最佳答案

将位置设为表头的绝对位置,宽度设为100%

position:absolute;
width:100%;

关于html - 如何让 div 背景图像缩放到页面大小?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28653177/

相关文章:

html - 背景 SVG 不会在 Bootstrap div 列中缩放

javascript - Material-UI Dialog 如何在对话框的右上角放置关闭按钮

c# - 如何将位图像素复制到其他位图,在 C# 中保留 alpha 透明度?

css - D3 TreeMap 中的渐变颜色

javascript - jquery.砌体。 imagesLoaded 插件未在 <head> 中运行

java - 如何从PNG图片构建个人JFrame

javascript - 如何内联页面布局多个部分需要的JS?

jquery - 使用 jQuery 更新带有下拉选择值的类

html - 删除 Vue 中 html 和 body 元素的边距和填充?

html - 调整视口(viewport)大小时 Bootstrap 出现意外行为