【问题标题】:horizontal scrolling react photo gallery水平滚动反应照片库
【发布时间】:2019-06-19 06:23:02
【问题描述】:

我使用 reakt 照片库库;我的组件获取图像数组作为道具,并将其转换为具有字段 {src、width、height} 的对象数组。一切正常,但问题是我有一个特定的块高度,画廊应该插入其中。块的高度明显小于画廊整个块的高度,所以我假设图片会水平滚动,并且它们仍然继续垂直滚动,我该如何进行水平滚动?

import React from 'react';
import Gallerys from 'react-photo-gallery';

const Content = styled.div`
  height: 700px;
  width: auto;
  overflow-x: scroll;
  img {
    border-radius:10px;
}
`;

class Gallery extends React.Component {

 render() {
   return (
     <Content>
       <Gallerys direction={'row'} margin={40} photos={images} />
     </Content>
   );
  }
 }

 export default Gallery;

【问题讨论】:

    标签: reactjs typescript


    【解决方案1】:

    请在这里查看答案https://codesandbox.io/embed/lively-sun-zqe7g

    注意:在你的 style.css/style.scss 中使用它

    //use in css
    .react-photo-gallery--gallery div {
      flex-flow: nowrap !important;
    }
    
    
    //use in sass/scss
    .react-photo-gallery--gallery{
      div{
        flex-flow: nowrap !important;
      }
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2016-08-05
      • 2015-06-08
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多