104 lines
No EOL
2 KiB
Markdown
104 lines
No EOL
2 KiB
Markdown
smart width and height (Given solution not working yet)
|
|
|
|
- Using min and max we can set the width to be appropriate for dynamic width and height
|
|
**Update : this wont work**
|
|
|
|
for eg:
|
|
|
|
```css
|
|
html,
|
|
body {
|
|
margin: 0;
|
|
padding: 0;
|
|
height: 100%;
|
|
}
|
|
|
|
.ShowSchools {
|
|
width: 100%;
|
|
height: 100vh;
|
|
background: rgb(240, 240, 240);
|
|
min-height: 515px;
|
|
}
|
|
|
|
.container {
|
|
width: 75%;
|
|
min-width: 400px;
|
|
min-height: 400px;
|
|
|
|
background: white;
|
|
|
|
/* Set height to a maximum of 100% or fit-content */
|
|
height: min(100%, fit-content);
|
|
|
|
margin: 0 auto;
|
|
|
|
border-radius: 10px;
|
|
box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
|
|
|
|
display: flex;
|
|
justify-content: space-around;
|
|
flex-wrap: wrap;
|
|
}
|
|
```
|
|
|
|
Here if we use 100% as height then it will cause overflow as height wont increase beyond 100% of container and if we set height as fit-content then height will be 0 if no min-height is set and also it wont occupy the 100% as default
|
|
|
|
this method if not working then use wrapper like this
|
|
|
|
```css
|
|
html,
|
|
body {
|
|
margin: 0;
|
|
padding: 0;
|
|
height: 100%;
|
|
// height: min(100%, fit-content);
|
|
}
|
|
|
|
.ShowSchools {
|
|
width: 100%;
|
|
// height: 100vh;
|
|
background: rgb(240, 240, 240);
|
|
min-height: 515px;
|
|
// height: max(100%, fit-content);
|
|
height: 100%;
|
|
}
|
|
|
|
.heading {
|
|
padding: 1px;
|
|
height: 100px;
|
|
h1 {
|
|
text-align: center;
|
|
}
|
|
// margin-top: 1rem;
|
|
margin-bottom: 1rem;
|
|
}
|
|
|
|
.container-wrapper {
|
|
width: 75%;
|
|
min-width: 400px;
|
|
min-height: 400px;
|
|
display: flex;
|
|
// align-items: center;
|
|
justify-content: center;
|
|
// height: 100%;
|
|
height: calc(100% - (100px + 16px + 1px + 2px));
|
|
background: white;
|
|
margin: 0 auto;
|
|
border-radius: 10px;
|
|
box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
|
|
}
|
|
|
|
.container {
|
|
width: 100%;
|
|
// height: calc(100% - (100px + 16px + 1px + 2px));
|
|
height: fit-content;
|
|
// height: max(100%, fit-content);
|
|
// height: calc(max(100% - (100px + 16px + 1px + 2px), fit-content));
|
|
// height: max(calc(100vh - (100px + 16px + 1px + 2px)), fit-content);
|
|
// overflow: auto;
|
|
|
|
display: flex;
|
|
justify-content: space-around;
|
|
flex-wrap: wrap;
|
|
}
|
|
``` |