tleunen / react-mdl

React Components for Material Design Lite
https://tleunen.github.io/react-mdl/
MIT License
1.76k stars 255 forks source link

How can I centralize an element? #321

Closed Natanael1234 closed 8 years ago

Natanael1234 commented 8 years ago

I found this example but don't found any source code showing how to implement.

Natanael1234 commented 8 years ago

Answer:

    return (
        <DataTable       onClick = { onSelection } 
                                     style={{width: '80%', margin: 'auto'}}
                         shadow  = { 0           }
                         rows    = { cells       } >
            <TableHeader name    = "id"                >Id          </TableHeader>
            <TableHeader name    = "nome"            >Name        </TableHeader>
            <TableHeader name    = "endereco"      >Address  </TableHeader>
            <TableHeader name    = "telefone"      >Phone  </TableHeader>

        </DataTable>

,

tleunen commented 8 years ago

It really depends on what you want to center. Your datatable example will indeed work to center a datatable.

For the example you mention in the first post, the article template, this is done because it used the Grid system. There is a 2 empty columns sized before the "main" part. Also, this system allows to automatically hide the 2 first columns when the view is in a "mobile" or "tablet" mode, to keep 100% width.