e-oj / Magic-Grid

A simple, lightweight Javascript library for dynamic grid layouts.
https://www.npmjs.com/package/magic-grid
MIT License
3.14k stars 144 forks source link

New Coder #13

Closed neal-an closed 5 years ago

neal-an commented 5 years ago

I am a new coder. I came across this awesome tool on Reddit. I have tried to set it up on a learning project I am working on, but I'm encountering a strange error. I can't seem to put anything inside of the container divs. Whatever I put in there are forced into the width of the box and ignore any attempts to be resized.

I figure I'm probably making a simple mistake, but any advice is welcome.

e-oj commented 5 years ago

Can you post the code?

neal-an commented 5 years ago

I can, but it really is as simple as putting two divs inside of "item1". They will show up side by side and I can't get them to stack.

e-oj commented 5 years ago

I'm assuming you're using the sample code (correct me if I'm wrong). If you take a look at the styles, you'll notice that every div inside ".container" has it's display set to flex (flexbox guide).

<style>
  .container div {
    width: 280px;
    height: 500px;
    background-color: antiquewhite;

    /* display set to flex */
    display: flex;

    /* flex properties */
    justify-content: center;
    align-items: center;

    border-radius: 8px;
  }
</style>

Change the display to "block" and it will behave the way you want. You should also delete the flex properties because they have no effect on a block display. Let me know if it works for you. More about the display property.

neal-an commented 5 years ago

That was it! I knew it had to be something super basic. Thanks for your help!

e-oj commented 5 years ago

No problem.