使用CSS裁剪图像以集中显示在屏幕上 [英] Crop Image To Center on Screen Resize with CSS

查看:69
本文介绍了使用CSS裁剪图像以集中显示在屏幕上的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试拍摄图像并将其居中显示在屏幕上。可以说图像是屏幕的整个宽度,例如1400px ---

I'm trying to take an image and center it on the screen. Lets say the image is the full width of your screen, say 1400px ---

当您调整浏览器窗口的大小时,我试图将图像裁剪掉,但是

When you resize the browser window, I'm trying to get the image to crop but stay centered as the browser window gets smaller.

css是否可能?

我尝试了一些方法有溢出:隐藏-没有成功。

I tried a few things with overflow:hidden - no success.

推荐答案

我先看一下背景尺寸,然后将其垂直和水平居中。

I would take a look at background-size and then just center it vertically and horizontally.

http:// css-tricks。 com / perfect-full-page-background-image /

这篇关于使用CSS裁剪图像以集中显示在屏幕上的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆