IMG 上的最大高度在固定 DIV 内不起作用

Bos*_*OSX 3 html css

什么我遇到的是,图像会被坐在虽然CSS是说应该坐在股利的方式过分max-height700

任何帮助表示赞赏

#largephotohold {
  border: 0px black solid;
  position: fixed;
  bottom: 0px;
  width: 90%;
  margin-left: 5%;
  background-color: white;
  text-align: center;
  border: 3px solid red;
  max-height: 700px;
}

#largephotohold IMG {
  max-height: 100%;
  max-width: 100%;
}
Run Code Online (Sandbox Code Playgroud)
<DIV id="largephotohold">
<img src="http://i.imgur.com/AUn1uj6.jpg">
</DIV>
Run Code Online (Sandbox Code Playgroud)

https://jsfiddle.net/e8nx0cto/

Mic*_*l_B 6

在元素上应用百分比高度时,需要在 parent 上设置 aheight。设置 amax-heightmin-height不起作用(如您所见)。必须是height财产。

对于插图,将 切换max-height: 700pxheight: 700px。现在您的图像高度有效。

替代解决方案:既然你告诉你的图像是max-height: 100%,一个容器的max-height: 700px,为什么不也告诉图像是max-height: 700px?这将带您解决百分比高度问题。

更多信息: