css - 标题横幅不会在手机/小型平板电脑上调整大小

标签 css responsive-design

由于该公司 Logo 的高度/设计,我们创建了包含它的标题图片。该标题图片位于此处:

http://tinyurl.com/oqkpvff

有人知道如何为移动设备/小型平板电脑自动调整标题图片的大小吗?

#title-container {
background-image: url("url of our image is here") !important;
background-position: left top !important;
background-repeat: no-repeat;
color: #FFFFFF;
display: block;
height: 250px;
max-width: 100% !important;
position: relative;
}

我确实尝试了 height: auto 但这也没有用。

最佳答案

您可以使用 background-size: contain;

Demo

#title-container {
    background-image: url("http://tinyurl.com/oqkpvff");
    background-position: left top !important;
    background-repeat: no-repeat;
    color: #FFFFFF;
    display: block;
    height: 250px;
    max-width: 100% !important;
    position: relative;
    background-size: contain;
}

contain

This keyword specifies that the background image should be scaled to be as large as possible >while ensuring both its dimensions are less than or equal to the corresponding dimensions of the background positioning area.

关于css - 标题横幅不会在手机/小型平板电脑上调整大小,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22621031/

相关文章:

CSS 访问QHeaderView item columns设置background-image,或者设置大图标给QHeaderView

css - 如何在左侧打开 Primefaces 子菜单?

css - 移动设备和桌面上的 img(响应式设计)

html - 不同 @media 宽度上的 CSS 网格顺序

html - 响应式设计 - DOM 元素限制和 HTML 与 SVG 性能

javascript - 在DataTable中更改页面时如何显示确认弹出窗口

html - HTML 中的两张图片,一张正在加载,另一张未加载

css - 选择中的彩色文本不适用于 chrome

css - Bootstrap 中有没有办法在小屏幕上将一列设置为 "split"?

css - 响应式导航栏不随 slider 缩小