css - 背景大小包含 AND 长度

标签 css background-image

我有一个 div,其背景图像的大小设置为包含。但是,图像是视网膜计算机(Macbook Pro 等)的双分辨率图像,所以我希望能够以某种方式让页面知道即使我说的是背景大小:包含 200x200 图像,它应该将其视为 100x100 图像。有什么办法吗?本质上,我想要这样的东西:

{
    background-position:center bottom;
    background-size:contain
    background-size-again:100px 100px; /*???*/
}

最佳答案

好的,你应该使用

background-size:cover 

这将强制图像保持高分辨率,然后将元素大小设置为您想要的大小,例如 100px x 100px

关于css - 背景大小包含 AND 长度,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23270438/

相关文章:

css - 使一个 div 在悬停在另一个 div 上时出现

jquery - 带有 margin-top 的下拉菜单

css - 将文本对齐到与中间对齐的图像的左侧

html - 为什么后台附件: fixed make background-size:cover resize to the window proportions?

css - WordPress 和背景图片

javascript - 我们如何提供鼠标单击功能以及鼠标悬停功能?

css - IE6/IE7 和透明背景错误 - 对所有这些错误的实用修复是什么?

html - 自动调整为 100% 宽度保持纵横比的表格的图像背景

css - 位置 :fixed within an overflow:hidden parent - cross-browser alternative to background-attachment:fixed?

css - 始终缩放的背景图像,因此不会出现任何正常的背景颜色