【问题标题】:Zooming inline block element to center instead of the left将内联块元素缩放到中心而不是左侧
【发布时间】:2018-03-20 06:43:49
【问题描述】:

所以我的布局在桌面屏幕上运行良好:查看顶部图像。

但是当在移动布局/放大时变成这样:(看中间的图像)。

所以我想要实现的是将图像放大到中心,如背景大小覆盖行为。 (看下图)

谁能帮我解决这个布局问题? 提前致谢。

【问题讨论】:

标签: html css styles responsive styling


【解决方案1】:

使用flexbox 来解决这个问题。

.center {
  display: flexbox;
  justify-content: center;
}

将此.center 类应用于容器盒。

查看此link,了解flexbox 的浏览器支持。

【讨论】:

  • 没问题先生 :)
【解决方案2】:

你可以将img设为绝对并添加

img{
   left:0;
   right:0;
   margin: auto;
   overflow:hidden;
}

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2012-09-09
    • 2019-09-26
    • 2013-08-04
    • 2015-05-14
    • 2015-11-22
    • 2015-04-27
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多