html - 是否高度 : auto for image stretch as much as the height of the png?

标签 html css

.q-team-images {
     width: 6.4rem;
     height: auto;
     padding-bottom: 1rem;
 }

上面的css样式是否会让图片的高度与其png图片的高度一致?

最佳答案

是的,如果它不破坏你的图像的比例,因为你已经设置了一个 width 它会按你的宽度缩放,所以它可能不会(取决于你的图像高度.

您还可以使用 max-widthmax-height

.q-team-images {
    max-width: 1280px; //your images max width
    max-height: 720px; // your images max height
    height: auto;
    width: auto;
    padding-bottom: 1rem;

}

关于html - 是否高度 : auto for image stretch as much as the height of the png?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44269291/

相关文章:

javascript - 根据用户的选择更改占位符文本

html - 如何让 sub div 不考虑其堂兄的高度?

html - 所有 img 都应该是 100% 的基本 Bootstrap 设置吗?

html - 如何仅为最后一个元素重置 CSS::after 样式?

javascript - 如何使用 JavaScript 迭代 XML 文件并在 HTML 网页中显示数据?

php - 在自定义 style.css 文件中的一些更改时,它没有显示 wordpress "[...]"中帖子页面的完整内容

html - :hover for background area around an image

twitter-bootstrap - 是否有任何解决方案可以在不破坏图像的情况下显示一系列大小不同且高度相同的图像?

不会出现 jquery 边框更改

html - CSS :not pseudo code not working