使用 css 防止或禁用 div 中的自动图像大小调整(使用引导程序)

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/14507224/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-29 21:25:49  来源:igfitidea点击:

Prevent or disable automatic image resize in a div with css (using bootstrap)

cssimagetwitter-bootstrap

提问by Hao Luo

I'm trying to show the original size of the image. Often that's bigger than the width of the div that's containing it.

我正在尝试显示图像的原始大小。通常这大于包含它的 div 的宽度。

In modern browsers, it gets automatically resized to fit the parent div. Even when I use overflow: autothe image still gets resized.

在现代浏览器中,它会自动调整大小以适合父 div。即使我使用overflow: auto图像仍然会调整大小。

So how can I prevent the image from getting resized when the outer div has a set width?

那么当外部 div 具有设置的宽度时,如何防止图像调整大小?

Thank you!

谢谢!

回答by Pavlo

Bootstrap have maximum width set to 100% on images. Change it:

Bootstrap 将图像的最大宽度设置为 100%。更改:

img {
    max-width: none;
}

回答by Mike

I used this one img {min-width:100%}

我用过这个 img {min-width:100%}