Thursday, April 14, 2022

resizable, draggable divs as border for exercising responsive layout

 We use storybook, and by default it shows you a canvas that is influenced by the shape needed by its children (i.e. the component you are building). You have an option to make it fullwidth, but even then it can be a little clumsy to resize the whole browser just to see your component shift.

Old school folks like maybe surprised you can trivially add a draggable corner to any div:

Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.

The style for that is just:

overflow: auto;
resize: both;
padding: 20px;
border: 2px dashed black;
width: 348px;

(The first two being the most "intesting")

No comments:

Post a Comment