【问题标题】:Bootstrap: Responsive Image in PanelBootstrap:面板中的响应式图像
【发布时间】:2016-04-16 11:05:22
【问题描述】:

我正在尝试在面板内放置响应式图像,以保持图像的纵横比,并且图像尽可能大,以免被截断。我试图弄乱CSS,但似乎没有任何效果。我正在使用带有 React.js (react-bootstrap) 的 Bootstrap。有没有人知道为什么这不起作用?谢谢!

举个例子:如果我的面板是 200x100,那么其中的图像可能是 100x100、200x50、50x100 等。

JS(内部渲染方法)

<Panel className='fixed-panel' bsStyle="info">
  <div className="panel-photo">
    <Image src={thumbPhotoUrl} responsive className="img-responsive center-block"/>
  </div>
</Panel>

CSS 文件

.fixed-panel {
  min-height: 300px;
  max-height: 300px;
}
.panel-photo {
  height: 185px;
  overflow: hidden;
}

【问题讨论】:

标签: javascript html css twitter-bootstrap reactjs


【解决方案1】:

根据您的要求,您不希望剪切或裁剪图像。所以你必须从.panel-photo 中删除overflow:hidden。然后在下面使用这个css:

.panel-photo img{
    width:100%;
    height: auto;
 }

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-07-08
    • 2017-01-12
    • 2014-04-14
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多