被点击的反应模式图像不显示大尺寸图像

问题描述 投票:0回答:1

我下面有代码可以在Image.Group中显示图像,且尺寸属性设置为“小”。在Image.Group一侧,我使用了从ModalImage导入的react-modal-image。单击图像时应该显示大尺寸的照片。但是事实是,当单击图像时,它仍然显示与以前相同大小的图像。我知道问题出在size="small",而ModalImage只是从Image.Group继承了prop。在这种情况下,如何在单击图像的情况下将尺寸覆盖大?

<Image.Group size="small">
  {photos &&
    photos.map(photo => (
      <LazyLoad key={photo.name} height={150}>
        <ModalImage
          small={photo.url}
          large={photo.url}
          alt={photo.name}
          hideDownload={true}
          hideZoom={true}
        />;
      </LazyLoad>
    ))}
</Image.Group>

被点击之前:enter image description here点击后:enter image description here

reactjs semantic-ui-react react-modal
1个回答
1
投票

我认为问题是由于height={150}组件上的Lazyload

如果要显示大小为150px的图像缩略图,则可以在ModalImage上添加类别名称,并将CSS应用于该类别名称。

<LazyLoad key={photo.name}>  //Remove height here
   <ModalImage
      small={photo.url}
      large={photo.url}
      alt={photo.name}
      hideDownload={true}
      hideZoom={true}
      className="modal-image"    //Add a class name here
   />;
</LazyLoad>

CSS应用于modal-image类别,

.modal-image{
  max-height: 150px !important;
}

Demo

© www.soinside.com 2019 - 2024. All rights reserved.