- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
img {
width: 200px;
height: 150px;
object-fit: cover;
}
<img src="https://res.cloudinary.com/wisdo/image/upload/v1589582065/mentored-sessions/New/Kim.jpg" />
最佳答案
这是因为图像本身保存不正确或格式不正确。
当我将原始图像下载到我的计算机时,我注意到了这一点,尽管图像尺寸为纵向(2208 x 2944),但预览显示为水平。
我在预览中打开它,将它旋转回原来的样子并保存了它。我把它放在 imgur 上以获取要使用的链接:
img {
width: 200px;
height: 150px;
object-fit: cover;
}
<img src="https://i.imgur.com/8OLakxR.jpg" />
background-position: cover
之所以有效,是因为在这种情况下,图像不是替换元素,而是浏览器获取呈现的图像并将其用作背景图像
object-fit
适用于替换元素,例如
video, img, iframe and embed
(是最常见的)。
object-fit: cover
- 对于 Chrome,图像是水平的而不是垂直的,因此它被拉伸(stretch)或者不正确地“适合”。
In CSS, a replaced element is an element whose representation is outside the scope of CSS; they're external objects whose representation is independent of the CSS formatting model.
Put in simpler terms, they're elements whose contents are not affected by the current document's styles. The position of the replaced element can be affected using CSS, but not the contents of the replaced element itself. Some replaced elements, such as elements, may have stylesheets of their own, but they don't inherit the styles of the parent document.
关于CSS object-fit 封面正在拉伸(stretch) Mac 上 Chrome 中的特定图像,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63019769/
我正在制作游戏并有一系列“房间”图像,这些图像使用 background-size: cover 进行缩放(并在必要时进行裁剪)以适应浏览器窗口。 . 我想将一些游戏内元素放置在这些图像的关键位置之上
我正在尝试构建一个像个人资料/封面布局这样的 facebook,但我正在为正确的布局而苦苦挣扎。 我目前拥有的: http://jsfiddle.net/kvEBF/
我正在尝试全屏拉伸(stretch)图像(封面):http://www.bootply.com/114850 我有一个简单的菜单和一个号召性用语按钮,但图像仅覆盖菜单并停在那里。 部分样式如下。 .s
我正在生成 epub 图书文件,但遇到了一个问题。它不读我的封面。这是 cover.xhtml 我做错了什么吗?关于 epub 创建的 IMB 文档告诉我,我唯一需要的是 cover.html 文件和
我使用了许多覆盖的背景图像。 如果我在页面内容区域和固定的左侧面板内使用相同的图像,它会非常频繁地闪烁。 转载: http://jsfiddle.net/7aUnL/8/ HTML:
我想获取文件的increment id,代码如下: // get increment id func GetID() uint64 { appIdLock.Lock() defer a
您好,我正在尝试让封面照片填满整个页面,但没有修复。我希望这样,一旦您开始滚动封面照片滚动和内容显示。我已将高度参数设置为 900 ish 以适合大多数屏幕,但我正在寻找一种方法让它覆盖所有浏览器/分
每当背景图像发生变化时,我都需要它来覆盖主体。我正在使用 background-size: cover,但它似乎不起作用。 body { position: relative; margi
我正在尝试使用以下方法获取 FB 页面的封面 url: $fql_query_url = "https://graph.facebook.com" ."/$fb_id[id]?fields=c
关于 ipad 和 iphone 的大小以及如何使用不同的 css,我遇到了几种方法和问题。真的有必要吗,尤其是现在 ipad 和 iphone 的版本越来越多,每个设备都有不同的背景? 几乎每个关于
.slide{ background: 50% 50% / cover; } background: 50% 50%/cover 有什么作用? 我知道后台语法是这样的 http://www.w
我正在尝试将多个 div 放置在背景图像之上,以产生很酷的效果。主要问题是网站是响应式的,图像也是如此 - 它是 background-size: cover 这使得在查看更大/更小的屏幕时很难将叠加
很难说出这里要问什么。这个问题模棱两可、含糊不清、不完整、过于宽泛或夸夸其谈,无法以目前的形式得到合理的回答。如需帮助澄清此问题以便重新打开,visit the help center . 关闭 1
您好,对于网上商店,我希望产品 block 像书本一样打开。并在 de inside-left 上显示图像(打开时) 我试过这样做。它工作正常,但我希望黑色 div 向左打开。这个将包含图像。当我放一
我正在创建一个不垂直滚动的页面。这是供引用的问题页面 - http://horizonwebtest.zxq.net/knowledgebase/ 除以下两点外,它运行良好: 在 iPad(可能是其他
我希望你能帮助我,我被这个问题困住了。 此处示例:http://myko.dk/pegasus/index.html (进行中) 我想让背景图像自动调整大小以适合浏览器宽度。现在,如您所见,图像在调整
如果有人能帮助我并告诉我如何用 CSS/HTML 制作背景封面,我将不胜感激。 我打算做的是制作一个 100% 宽度和 270 像素高度的封面,这将适合并且不会拉伸(stretch)我的图像,我不介意
今天我发现 Firefox 18.0.2 有一个奇怪的行为。即使更新到 FF19.0 也无济于事。 我需要创建具有动态大小并保持特定纵横比的缩略图。可能还有其他更好的解决方案,如下所示。 Html:
我用过Jcrop广泛,但我想以与 Facebook 用于裁剪其封面图像非常相似的方式裁剪图像。 因此,我希望 div 具有某种固定大小,其中背景保存其原始大小的可拖动图像,用户拖动该图像并找到要裁剪的
我正在从图片选择器中挑选一张图片,然后我想更改该图片作为 Facebook 封面的比例。我有一张图片,假设它的分辨率为 640 宽和 480 高,我想将其更改为 facebook 封面(851 像素宽
我是一名优秀的程序员,十分优秀!