English 中文(简体)
a. 装成 im,不增加高温
原标题:Fitting an img to div, without the div expanding height-wise
  • 时间:2023-12-11 22:51:14
  •  标签:
  • html
  • css
问题回答

在图像装上之前,所有物品都被打上了折扣......但当装上时,当布满时,就会被打上。 因此,这无疑是打破布局的形象本身。

因此,你需要将“滚动”的图像(out>,将其与的链接:及其母体为position: relative。 这保证了图像不会影响布局。

body {
  padding: 0;
  background-color: black;
}

.container {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100vh;
  display: flex;
  flex-direction: column;
}

.top {
  flex: 1;
  display: flex;
  flex-direction: row;
}

.image_viewer {
  flex: 1;
  width: 80%;
  display: flex;
  flex-direction: column;
}

.image_container {
  flex: 1;
  position: relative;
}

.image_container img {
  position: absolute;
  height: 100%;
  width: 100%;
  object-fit: scale-down;
}

.controls {
  background-color: red;
  color: white;
  text-align: center;
}

.sidebar {
  width: 20%;
  background-color: blue;
  color: white;
}

.bottom {
  height: 100px;
  background-color: green;
  text-align: center;
}
<div class="container">
  <div class="top">
    <div class="image_viewer">
      <div class="image_container">
        <img src="https://picsum.photos/400/800">
      </div>
      <div class="controls">
        controls go here
      </div>
    </div>
    <div class="sidebar">
      sidebar goes here
    </div>
  </div>
  <div class="bottom">
    thumbnails go here
  </div>
</div>

在管理这一幻灯之后,使用full page链接测试反应能力。

PS。 令人感兴趣的是,地貌或地貌并不打破你的布局,而是它唯一的漏洞。 我不理解造成这种情况的原因,但如果其他人能够解释,我很想知道。





相关问题
CSS working only in Firefox

I am trying to create a search text-field like on the Apple website. The HTML looks like this: <div class="frm-search"> <div> <input class="btn" type="image" src="http://www....

image changed but appears the same in browser

I m writing a php script to crop an image. The script overwrites the old image with the new one, but when I reload the page (which is supposed to pickup the new image) I still see the old one. ...

Firefox background image horizontal centering oddity

I am building some basic HTML code for a CMS. One of the page-related options in the CMS is "background image" and "stretch page width / height to background image width / height." so that with large ...

Separator line in ASP.NET

I d like to add a simple separator line in an aspx web form. Does anyone know how? It sounds easy enough, but still I can t manage to find how to do it.. 10x!