I have two rows with columns. The bottom bar later contains blocks which matches the ruler numbers. So both rows should have the same length if one of them exceeds the parent width (overflow scroll).
But currently the bottom bar is always 100% of the initial parent width. But I expected the following:
The first row width increases the inner width of the parent. The bottom row should fill that dynamic width. Is there a way to keep this element separated as it is, but have the same width?
No JavaScript.
There are similar questions and solution on the web / stackoverflow. But nothing works in my case. It looks trivial, but I have no idea. I feel like a noob. ^^ The DOM structure should be retained.
Background: I want to implement a ruler with some annotations at the bottom. Blocks with start and stop. I could use a canvas to achieve that. But I would prefer HTML. I would be grateful for any help.
Stackblitz Demo
body {
width: 100%;
height: 100%;
margin: 0;
}
.container {
width: 100%;
overflow-x: auto;
}
.wrapper {
display: flex;
}
.text {
min-width: 30px;
flex: 1;
text-align: center;
}
.text:nth-child(even) {
background-color: #ddd;
}
.bar {
background-color: green;
height: 30px;
flex: 1;
}
<div class="container">
<div class="wrapper">
<div class="text">1</div>
<div class="text">2</div>
<div class="text">3</div>
<div class="text">4</div>
<div class="text">5</div>
<div class="text">6</div>
<div class="text">7</div>
<div class="text">8</div>
<div class="text">9</div>
<div class="text">10</div>
<div class="text">11</div>
<div class="text">12</div>
<div class="text">13</div>
<div class="text">14</div>
<div class="text">15</div>
<div class="text">16</div>
<div class="text">17</div>
<div class="text">18</div>
<div class="text">19</div>
<div class="text">20</div>
<div class="text">21</div>
<div class="text">22</div>
<div class="text">23</div>
<div class="text">24</div>
<div class="text">25</div>
<div class="text">26</div>
<div class="text">27</div>
<div class="text">28</div>
<div class="text">29</div>
<div class="text">30</div>
</div>
<div class="bar"></div>
</div>
I made it working with one more additional wrapper div for bar and elements.
.scroll {
width: 500px;
overflow: auto;
}
.scroll__wrapper {
width: fit-content;
}
.scroll__elements {
display: flex;
background: pink;
width: fit-content;
}
.text {
flex-shrink: 0;
width: 50px;
}
.scroll__bar {
height: 50px;
background: red;
}
<div class="scroll">
<div class="scroll__wrapper">
<div class="scroll__elements">
<div class="text">1</div>
<div class="text">2</div>
<div class="text">3</div>
<div class="text">4</div>
<div class="text">5</div>
<div class="text">6</div>
<div class="text">7</div>
<div class="text">8</div>
<div class="text">9</div>
<div class="text">10</div>
<div class="text">11</div>
<div class="text">12</div>
<div class="text">13</div>
<div class="text">14</div>
<div class="text">15</div>
<div class="text">16</div>
<div class="text">17</div>
<div class="text">18</div>
<div class="text">19</div>
<div class="text">20</div>
<div class="text">21</div>
<div class="text">22</div>
<div class="text">23</div>
<div class="text">24</div>
<div class="text">25</div>
<div class="text">26</div>
<div class="text">27</div>
<div class="text">28</div>
<div class="text">29</div>
<div class="text">30</div>
</div>
<div class="scroll__bar">Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aliquam vitae ligula laoreet, iaculis dui sed, ultrices risus. Lorem ipsum dolor sit amet, consectetur adipiscing elit.</div>
</div>
</div>
You need to set fit-content to min-width of your .container. This works with dynamic width.
See Stackblitz.
body {
width: 100%;
height: 100%;
margin: 0;
font-family: Arial, Helvetica, sans-serif;
}
.component {
display: block;
width: 100%;
overflow-x: auto;
}
.container {
display: flex;
flex-direction: column;
min-width: fit-content;
}
.ruler {
display: flex;
}
.text {
flex: 1;
min-width: 30px;
text-align: center;
}
.text:nth-child(even) {
background-color: #ddd;
}
.bar {
position: relative;
background-color: green;
flex: 1;
min-height: 30px;
}
.log {
position: absolute;
left: 30%;
width: 30%;
height: 100%;
background-color: yellow;
display: flex;
justify-content: center;
align-items: center;
}
<div class="component">
<div class="container">
<div class="ruler">
<div class="text">1</div>
<div class="text">2</div>
<div class="text">3</div>
<div class="text">4</div>
<div class="text">5</div>
<div class="text">6</div>
<div class="text">7</div>
<div class="text">8</div>
<div class="text">9</div>
<div class="text">10</div>
<div class="text">11</div>
<div class="text">12</div>
<div class="text">13</div>
<div class="text">14</div>
<div class="text">15</div>
<div class="text">16</div>
<div class="text">17</div>
<div class="text">18</div>
<div class="text">19</div>
<div class="text">20</div>
<div class="text">21</div>
<div class="text">22</div>
<div class="text">23</div>
<div class="text">24</div>
<div class="text">25</div>
<div class="text">26</div>
<div class="text">27</div>
<div class="text">28</div>
<div class="text">29</div>
<div class="text">30</div>
</div>
<div class="bar">
<div class="log"><span>Some Log</span></div>
</div>
</div>
</div>
Related
I hope someone can help me to end my 16 hour search. I have to make
six responsive squares in a 2 x 3 raster.
Inside the square there has to be a responsive circle.
Inside the circle there has to be a centered letter.
I have to use Flexbox.
I am not allowed to use Grid and/or tables.
The squares and circles need to keep their aspect ratio and must fill the container.
CSS-only
div {
display: flex;
flex: 1;
justify-content: space-between;
font-size: 10rem;
}
.blokrij {
flex-direction: column;
width: 50%;
}
.vierkant {
background-color: hsla(26, 100%, 50%, 1.00);
flex: 1 1 auto;
max-width: 100%;
border-radius: 10%;
margin 1px;
}
.rond {
background-color: blue;
border-radius: 50%;
}
<div class="container">
<div class="blokrij">
<div class="vierkant">
<div class="rond"></div>L</div>
<div class="vierkant">
<div class="rond"></div>O</div>
<div class="vierkant">
<div class="rond"></div>I</div>
</div>
<div class="blokrij">
<div class="vierkant">
<div class="rond"></div>L</div>
<div class="vierkant">
<div class="rond"></div>O</div>
<div class="vierkant">
<div class="rond"></div>I</div>
</div>
</div>
I'm so frustrated I cant figure out what the hell I have to do. Especially because I know how to fix it with GRID.
Thansk for helping in Advance!
It is better to assign different codes to their own sections
The text is not written inside the circle
The ratios are not set correctly
Sizes are not set correctly
I set margin: 10px; and padding: 10px; for better and more clarity.
You might say that circles are not precise and are more like ellipses
This is true because they are measured relative to the screen
They may have different sizes in different sizes
.container{
width:100%;
height: 100vh;
display: flex;
}
.blokrij {
display: flex;
flex-direction: column;
width: 50%;
height: 100%;
}
.vierkant {
background-color: hsla(26, 100%, 50%, 1.00);
border-radius: 10%;
margin 1px;
height: 100%;
margin: 10px;
padding: 10px;
}
.rond {
height: 100%;
background-color: blue;
border-radius: 50%;
display: flex;
align-items: center;
justify-content: center;
font-size: 10rem;
}
<div class="container">
<div class="blokrij">
<div class="vierkant">
<div class="rond">L</div>
</div>
<div class="vierkant">
<div class="rond">O</div>
</div>
<div class="vierkant">
<div class="rond">I</div>
</div>
</div>
<div class="blokrij">
<div class="vierkant">
<div class="rond">L</div>
</div>
<div class="vierkant">
<div class="rond">O</div>
</div>
<div class="vierkant">
<div class="rond">I</div>
</div>
</div>
</div>
If you want the circles and squares to be exactly the exact circle and square, you can measure exactly with px , rem, ...
For example:
.container{
width:400px;
height: 400px;
display: flex;
}
.blokrij {
display: flex;
flex-direction: column;
width: 50%;
height: 100%;
}
.vierkant {
background-color: hsla(26, 100%, 50%, 1.00);
border-radius: 10%;
margin 1px;
height: 100%;
margin: 5px;
padding: 5px;
}
.rond {
height: 100%;
background-color: blue;
border-radius: 50%;
display: flex;
align-items: center;
justify-content: center;
font-size: 10rem;
}
<div class="container">
<div class="blokrij">
<div class="vierkant">
<div class="rond">L</div>
</div>
<div class="vierkant">
<div class="rond">O</div>
</div>
<div class="vierkant">
<div class="rond">I</div>
</div>
</div>
<div class="blokrij">
<div class="vierkant">
<div class="rond">L</div>
</div>
<div class="vierkant">
<div class="rond">O</div>
</div>
<div class="vierkant">
<div class="rond">I</div>
</div>
</div>
</div>
You have to give the circles a dedicated width and height, put the letters inside them and define for all flex-items the centering with justify-content and align-items. For the responsiveness you should define width and height of the circle and the font-size with the same responsive dimension, for example vw. The width for the columns isn't necessary.
Working example:
div {
display: inline-flex;
flex: 1;
justify-content: center;
align-items: center;
font-size: 10vw;
}
.blokrij {
flex-direction: column;
}
.vierkant {
background-color:hsla(26,100%,50%,1.00);
border-radius: 10%;
margin: 1px;
}
.rond {
width: 20vw;
height: 20vw;
background-color: blue;
border-radius: 50%;
}
<div class="container">
<div class="blokrij">
<div class="vierkant">
<div class="rond">L</div>
</div>
<div class="vierkant">
<div class="rond">O</div>
</div>
<div class="vierkant">
<div class="rond">I</div>
</div>
</div>
<div class="blokrij">
<div class="vierkant">
<div class="rond">L</div>
</div>
<div class="vierkant">
<div class="rond">O</div>
</div>
<div class="vierkant">
<div class="rond">I</div>
</div>
</div>
</div>
I have a flex container that wraps some cards. I have implemented a horizontal scroller with flex(using flex-nowrap). The flex wrapper container is subjected to have a 36px left spacing and a 0px right spacing initially. The catch here is after the last card is scrolled I need to have a 36px right spacing.
here is what I did so far
*{
box-sizing: border-box;
}
h2 {
margin: 0;
}
body {
background: cadetblue;
}
.container {
width: 500px;
margin: 0 auto;
background: #000;
padding: 20px 36px;
}
.scroll-wrapper {
overflow: hidden;
margin-right: -36px;
}
.scroll-inner {
display: flex;
flex-flow: row nowrap;
overflow: auto;
margin: 0px -16px;
}
.card {
height: 250px;
width: 75%;
flex: 1 0 75%;
padding: 0px 16px;
}
.inner-wrapper {
background: #fff;
height: 250px;
}
<div class="container">
<div class="scroll-wrapper">
<div class="scroll-inner">
<div class="card">
<div class="inner-wrapper"><h2>Card</h2></div>
</div>
<div class="card">
<div class="inner-wrapper"><h2>Card</h2></div>
</div>
<div class="card">
<div class="inner-wrapper"><h2>Card</h2></div>
</div>
<div class="card">
<div class="inner-wrapper"><h2>Card</h2></div>
</div>
<div class="card">
<div class="inner-wrapper"><h2>Card</h2></div>
</div>
<div class="card">
<div class="inner-wrapper"><h2>Card</h2></div>
</div>
<div class="card">
<div class="inner-wrapper"><h2>Card</h2></div>
</div>
<div class="card">
<div class="inner-wrapper"><h2>Card</h2></div>
</div>
<div class="card">
<div class="inner-wrapper"><h2>Card</h2></div>
</div>
</div>
</div>
</div>
I have given a negative right margin for the wrapper to make it look like it's flowing from the right.
Once the last element is scrolled/reached I want it to look something like this
enter image description here
One thing I noticed is my scroll-inner(flex-nowrap) is not wrapping up the entire children. I presumed if we have five children each having width 50px. The scroll-inner should show a scrollable width of 250px, Unfortunately, it's not how flex is behaving. Any help or suggestion is much appreciated.
Updating few images that show what I'm really looking for
During scrolling
After scrolling till the last card
Try
.scroll-wrapper {
overflow: hidden;
margin: auto;
}
.scroll-inner {
display: flex;
flex-flow: row nowrap;
overflow: auto;
margin: auto;
}
I have found a fix and hope this help someone.
*{
box-sizing: border-box;
}
h2 {
margin: 0;
}
body {
background: cadetblue;
}
.container {
width: 500px;
margin: 0 auto;
background: #000;
padding: 20px 36px;
}
.scroll-wrapper {
overflow: hidden;
margin-right: -36px;
}
.scroll-inner {
display: flex;
flex-flow: row nowrap;
overflow: auto;
margin: 0px;
}
.card {
height: 250px;
width: 75%;
flex: 1 0 75%;
padding-right: 40px;
margin-right: -8px;
}
.inner-wrapper {
background: #fff;
height: 250px;
}
<div class="container">
<div class="scroll-wrapper">
<div class="scroll-inner">
<div class="card">
<div class="inner-wrapper"><h2>Card</h2></div>
</div>
<div class="card">
<div class="inner-wrapper"><h2>Card</h2></div>
</div>
<div class="card">
<div class="inner-wrapper"><h2>Card</h2></div>
</div>
<div class="card">
<div class="inner-wrapper"><h2>Card</h2></div>
</div>
<div class="card">
<div class="inner-wrapper"><h2>Card</h2></div>
</div>
<div class="card">
<div class="inner-wrapper"><h2>Card</h2></div>
</div>
<div class="card">
<div class="inner-wrapper"><h2>Card</h2></div>
</div>
<div class="card">
<div class="inner-wrapper"><h2>Card</h2></div>
</div>
<div class="card">
<div class="inner-wrapper"><h2>Card</h2></div>
</div>
</div>
</div>
</div>
Please do answer if someone has a better solution!! Thanks
I want a layout with a header, body, and footer. I do not want to use display: fixed, so I'm only scrolling the body. I use flex-grow: 1 to force the body section to fill the height.
The body has 4 columns. The columns are taller than the height of the body, so the body scrolls. However, the columns do not scroll, only their content.
In this codepen, scroll the middle section with the 4 columns. Note the gold background of the columns does not scroll. Instead, you see the orange background of the body.
How do I get the body content area to fill the screen if there's less content but also have the content background expand with the content when it scrolls? I've tried adding clearing div's and setting the column height to 100%.
Video illustration of the problem: http://recordit.co/eGpT87EmPp
* {
box-sizing: border-box;
padding: 0;
margin: 0;
}
html,
body {
height: 100vh;
}
.App {
background: red;
display: flex;
flex-direction: column;
height: 100vh;
}
.App .Header {
background: violet;
display: flex;
min-height: 2rem;
}
.App .Header .Player {
background: pink;
flex: 1 1;
text-align: center;
}
.App .Body {
background: orange;
display: flex;
flex-grow: 1;
overflow-y: scroll;
}
.App .Body .Column {
background: gold;
box-shadow: inset -1px 0 0 0 black;
display: flex;
flex-direction: column;
flex: 1 1;
padding-top: 1rem;
}
.App .Tile {
background: #111;
color: white;
margin: 0 auto 1rem;
padding: 5rem 0;
text-align: center;
width: 4rem;
}
.App .Footer {
background: deepskyblue;
min-height: 2rem;
}
<div class="App">
<div class="Header">
<div class="Player">Player</div>
<div class="Player">Player</div>
<div class="Player">Player</div>
<div class="Player">Player</div>
</div>
<div class="Body">
<div class="Column">
<div class="Tile">0</div>
<div class="Tile">1</div>
<div class="Tile">2</div>
<div class="Tile">3</div>
<div class="Tile">4</div>
<div class="Tile">5</div>
<div class="Tile">6</div>
<div class="Tile">7</div>
<div class="Tile">8</div>
<div class="Tile">9</div>
<div class="Tile">10</div>
<div class="Tile">11</div>
<div class="Tile">12</div>
<div class="Tile">13</div>
<div class="Tile">14</div>
<div class="Tile">15</div>
<div class="Tile">16</div>
<div class="Tile">17</div>
<div class="Tile">18</div>
<div class="Tile">19</div>
</div>
<div class="Column">
<div class="Tile">0</div>
<div class="Tile">1</div>
<div class="Tile">2</div>
<div class="Tile">3</div>
<div class="Tile">4</div>
<div class="Tile">5</div>
<div class="Tile">6</div>
<div class="Tile">7</div>
<div class="Tile">8</div>
<div class="Tile">9</div>
<div class="Tile">10</div>
<div class="Tile">11</div>
<div class="Tile">12</div>
<div class="Tile">13</div>
<div class="Tile">14</div>
<div class="Tile">15</div>
<div class="Tile">16</div>
<div class="Tile">17</div>
<div class="Tile">18</div>
<div class="Tile">19</div>
</div>
<div class="Column">
<div class="Tile">0</div>
<div class="Tile">1</div>
<div class="Tile">2</div>
<div class="Tile">3</div>
<div class="Tile">4</div>
<div class="Tile">5</div>
<div class="Tile">6</div>
<div class="Tile">7</div>
<div class="Tile">8</div>
<div class="Tile">9</div>
<div class="Tile">10</div>
<div class="Tile">11</div>
<div class="Tile">12</div>
<div class="Tile">13</div>
<div class="Tile">14</div>
<div class="Tile">15</div>
<div class="Tile">16</div>
<div class="Tile">17</div>
<div class="Tile">18</div>
<div class="Tile">19</div>
</div>
<div class="Column">
<div class="Tile">0</div>
<div class="Tile">1</div>
<div class="Tile">2</div>
<div class="Tile">3</div>
<div class="Tile">4</div>
<div class="Tile">5</div>
<div class="Tile">6</div>
<div class="Tile">7</div>
<div class="Tile">8</div>
<div class="Tile">9</div>
<div class="Tile">10</div>
<div class="Tile">11</div>
<div class="Tile">12</div>
<div class="Tile">13</div>
<div class="Tile">14</div>
<div class="Tile">15</div>
<div class="Tile">16</div>
<div class="Tile">17</div>
<div class="Tile">18</div>
<div class="Tile">19</div>
</div>
</div>
<div class="Footer">Footer</div>
</div>
So it doesn't look like you want the individual columns to scroll. If I've misinterpreted that requirement, then the solution is simple.
Make these adjustments to your code:
.Body {
background: orange;
display: flex;
flex-grow: 1;
/* overflow-y: scroll; */
min-height: 0; /* new */
}
.Column {
overflow: auto; /* new */
background: gold;
box-shadow: inset -1px 0 0 0 black;
display: flex;
flex-direction: column;
flex: 1 1;
padding-top: 1rem;
}
codepen
Here's an explanation for the modifications above: Why don't flex items shrink past content size?
If you just want the .Body element to scroll, add a wrapper:
<div class="Body">
<section><!---- NEW ----->
<div class="Column">
<div class="Tile">0</div>
<div class="Tile">1</div>
<div class="Tile">2</div>
<div class="Tile">3</div>
. . .
.Body {
background: orange;
flex-grow: 1;
overflow: auto;
}
section {
display: flex;
}
codepen
Here's an explanation for the modifications above: Make background color extend into overflow area
So I have a structure pretty similar to the snippet below.
The issue I have is that I am trying to make it so that the divs such as child always take the same height relative to the container even if they are empty. So if there are two children they have to be 50% of the parent if there are three children 33.3% of the parent and ec.
Did a lot of digging, tried usingflex-grow and setting it on the children, adding an after content on the childContent class if it was empty but the empty children still collapse.
Is it even possible to achieve equal heights on the children without using js and fixed heights and if yes how?
.container {
display: flex;
flex-direction: column;
height: 100%;
width: 100%;
overflow: auto;
}
.child {
height: 100%;
display: flex;
flex-direction: column;
}
.childHeader {
display: flex;
flex-direction: row;
}
.headerItem {
background-color: red;
}
.childContent {
background-color: white;
}
.childContent:empty:after {
content: '.';
visibility: hidden;
min-height: 300px;
}
.contentItem {
background-color: skyblue;
border: 3px solid black;
}
<div class="container">
<div class="child">
<div class="childHeader">
<div class="headerItem">1</div>
<div class="headerItem">2</div>
<div class="headerItem">3</div>
<div class="headerItem">4</div>
<div class="headerItem">5</div>
<div class="headerItem">6</div>
<div class="headerItem">7</div>
</div>
<div class="childContent">
<div class="contentItem">1</div>
<div class="contentItem">2</div>
<div class="contentItem">3</div>
<div class="contentItem">4</div>
<div class="contentItem">5</div>
<div class="contentItem">6</div>
<div class="contentItem">7</div>
</div>
</div>
<div class="child">
<div class="childHeader">
<div class="headerItem">1</div>
<div class="headerItem">2</div>
<div class="headerItem">3</div>
<div class="headerItem">4</div>
<div class="headerItem">5</div>
<div class="headerItem">6</div>
<div class="headerItem">7</div>
</div>
<div class="childContent">
</div>
</div>
<div class="child">
<div class="childHeader">
<div class="headerItem">1</div>
<div class="headerItem">2</div>
<div class="headerItem">3</div>
<div class="headerItem">4</div>
<div class="headerItem">5</div>
<div class="headerItem">6</div>
<div class="headerItem">7</div>
</div>
<div class="childContent">
</div>
</div>
</div>
Check this out, I'm not really sure if this is what you want to do.
I just added min-height: calc(100vh - 60px); in your .childContent
.container {
display: flex;
flex-direction: column;
height: 100%;
width: 100%;
overflow: auto;
}
.child {
display: flex;
flex-direction: column;
}
.childHeader {
display: flex;
flex-direction: row;
}
.headerItem {
display:flex;
flex-basis:100%;
background-color: red;
}
.childContent {
background-color: grey;
position: relative;
display: block;
min-height: calc(80vh - 60px);
}
.childContent:empty::after {
content: '.';
visibility: hidden;
}
.contentItem {
background-color: skyblue;
border: 3px solid black;
}
<div class="container">
<div class="child">
<div class="childHeader">
<div class="headerItem">1</div>
<div class="headerItem">2</div>
<div class="headerItem">3</div>
<div class="headerItem">4</div>
<div class="headerItem">5</div>
<div class="headerItem">6</div>
<div class="headerItem">7</div>
</div>
<div class="childContent">
<div class="contentItem">1</div>
<div class="contentItem">2</div>
<div class="contentItem">3</div>
<div class="contentItem">4</div>
<div class="contentItem">5</div>
<div class="contentItem">6</div>
<div class="contentItem">7</div>
</div>
</div>
<div class="child">
<div class="childHeader">
<div class="headerItem">1</div>
<div class="headerItem">2</div>
<div class="headerItem">3</div>
<div class="headerItem">4</div>
<div class="headerItem">5</div>
<div class="headerItem">6</div>
<div class="headerItem">7</div>
</div>
<div class="childContent">
</div>
</div>
<div class="child">
<div class="childHeader">
<div class="headerItem">1</div>
<div class="headerItem">2</div>
<div class="headerItem">3</div>
<div class="headerItem">4</div>
<div class="headerItem">5</div>
<div class="headerItem">6</div>
<div class="headerItem">7</div>
</div>
<div class="childContent">
</div>
</div>
</div>
Check this one out https://developer.mozilla.org/en-US/docs/Web/CSS/calc
I have a dummy screen with background image. The background image correctly expands or contracts with the size of the viewport. I have dummy flexbox content that I intentionally make overflow the bottom of the page.
The scrollbar correctly appears, but it will not scroll far enough to show all the content that overflowed.
Apologies: the content is varied so I can tell what IS NOT showing.
Dummy header menu bar is fine.. it is supposed to scroll up - and it does.
CSS:
html {
box-sizing: border-box;
}
body {
box-sizing: border-box;
overflow-y: auto;
min-height: 100vh;
width: 100%;
margin: 0; padding: 0; border: 0; cursor: default
}
ul {
list-style: none;
li {
display: inline;
margin-left: 50px;
margin-top: 50px;
}
}
.blockStyleEven {
display: flex;
flex-direction: row;
color: white;
justify-content: space-evenly;
}
.blockSpaceAround {
display: flex;
flex-direction: row;
color: white;
justify-content: space-around;
}
.blockSpaceBetween {
display: flex;
flex-direction: row;
color: white;
justify-content: space-between;
}
.blockStart {
display: flex;
flex-direction: row;
color: white;
justify-content: flex-start;
}
.blockEnd {
display: flex;
flex-direction: row;
color: white;
justify-content: flex-end;
}
.blockCenter {
display: flex;
flex-direction: row;
color: white;
justify-content: center;
}
.maroon {
width: 100px;
height: 100px;
background-color: maroon;
}
.red {
width: 100px;
height: 100px;
background-color: red;
}
.green {
width: 100px;
height: 100px;
background-color: green;
}
.blue {
width: 100px;
height: 100px;
background-color: blue;
}
.workspace {
background: url("././Features.jpg") no-repeat center center fixed;
background-size: cover;
height: 100vh;
width: 100vw;
overflow: hidden;
h1 {
color: #E0B228;
}
h2 {
color: #2856E0;
}
}
HTML:
<div [ngStyle]="{'width': '100vw', 'height': '100vh'}">
<div [ngStyle]="{'display': 'flex', 'flex-direction': 'column'}">
<div [ngStyle]="{'background-color': 'beige'}">
<ul>
<li>First</li>
<li>Second</li>
<li>Third</li>
</ul>
</div>
<div class="workspace">
<div class="blockStyleEven">
<div class="maroon">space-evenly</div>
<div class="red">RED</div>
<div class="green">GREEN</div>
<div class="blue">BLUE</div>
</div>
<div class="blockSpaceAround">
<div class="maroon">space-around</div>
<div class="red">RED</div>
<div class="green">GREEN</div>
<div class="blue">BLUE</div>
</div>
<div class="blockSpaceBetween">
<div class="maroon">space-between</div>
<div class="red">RED</div>
<div class="green">GREEN</div>
<div class="blue">BLUE</div>
</div>
<div class="blockStart">
<div class="maroon">start</div>
<div class="red">RED</div>
<div class="green">GREEN</div>
<div class="blue">BLUE</div>
</div>
<div class="blockEnd">
<div class="maroon">end</div>
<div class="red">RED</div>
<div class="green">GREEN</div>
<div class="blue">BLUE</div>
</div>
<div class="blockCenter">
<div class="maroon">center</div>
<div class="red">RED</div>
<div class="green">GREEN</div>
<div class="blue">BLUE</div>
</div>
<div class="blockStyleEven">
<div class="maroon">space-evenly</div>
<div class="red">RED</div>
<div class="green">GREEN</div>
<div class="blue">BLUE</div>
</div>
<div class="blockSpaceAround">
<div class="maroon">space-around</div>
<div class="red">RED</div>
<div class="green">GREEN</div>
<div class="blue">BLUE</div>
</div>
<div class="blockSpaceBetween">
<div class="maroon">space-between</div>
<div class="red">RED</div>
<div class="green">GREEN</div>
<div class="blue">BLUE</div>
</div>
<div class="blockStart">
<div class="maroon">start</div>
<div class="red">RED</div>
<div class="green">GREEN</div>
<div class="blue">BLUE</div>
</div>
<div class="blockEnd">
<div class="maroon">end</div>
<div class="red">RED</div>
<div class="green">GREEN</div>
<div class="blue">BLUE</div>
</div>
<div class="blockCenter">
<div class="maroon">center</div>
<div class="red">RED</div>
<div class="green">GREEN</div>
<div class="blue">BLUE</div>
</div>
</div>
</div>
</div>
Thanks in advance.
Yogi
Finally figured it out. The problem was the scrollbar was "too short" to show all the content. This was because my workspace class was on a div below the dummy menu bar. When I put the workspace (containing Margin: auto) on the outer move div, it worked perfectly.
Thanks for all your help.
Apologies for the earlier poor formatting, which has now been cleaned up.
Yogi