📜  响应式容器居中 - Html 代码示例

📅  最后修改于: 2022-03-11 14:52:56.805000             🧑  作者: Mango

代码示例1
.container {
  width: 400px;
  height: 300px;
  background-color: #ccc;
  position: absolute;
  /*it can be fixed too*/
  left: 0;
  right: 0;
  top: 0;
  bottom: 0;
  margin: auto;
  /*this to solve "the content will not be cut when the window is smaller than the content": */
  max-width: 100%;
  max-height: 100%;
  overflow: auto;
}