xudafeng / autoresponsive-react

⚛️ Auto Responsive Layout Library For React

Home Page:https://xudafeng.github.io/autoresponsive-react

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Suggestions for centering the resulting container?

adcooley opened this issue · comments

It appears that after the container is rendered, the container width > the width of all the items. I tried calculating the # of columns that would be rendered myself and adding padding to adjust, but it's not quite right.

Anyone have a suggestion for this?

What are you going to do? @adcooley

I agree. Its an important feature to have. For example: I have grid cells of width 200 and screen width is 500. If I set cellMargin as 20 and margin on individual cells as 20 then I am still left with 60 pixels on the right compared to 20 pixels on the left.

Can you give some pointers on how this can be solved?

screen shot 2016-11-24 at 9 44 57 am

Any elegant solution to this yet?

可以给 AutoResponsive 的父元素 div 设置样式,例如

width: 650,
margin-left: auto,
margin-right: auto,

如果是2列,React native 也可以这样设置

itemMargin={(screenWidth - 160 * 2) / 3}

子元素样式

width: 160,
transform: [{translateX: (screenWidth - 160 * 2) / 3}],