I am trying to create the layout shown in the diagram below with css flex, I am part way there but need to help with the 3 boxes on the right and the box on the bottom, can anyone help?
layout view needed:
this is how far i got: my attempt on the view on jsfiddle
.game-heading{background: #a3a3a3;}
header{
display: flex;
}
article{
display: flex;
}
.scores {
display: flex;
flex-wrap: wrap;
flex: 1;
line-height: 1;
}
.period {
background: #c29d31;
padding: 5px 10px;
text-align: center;
}
.results{
display: flex;
flex-direction: column;
}
.score-nr {
background: #9E8231;
flex: 1;
line-height: 10px;
padding: 6px;
}
.competitors{
color: #2d2929;
flex-direction: row;
align-items: flex-start;
float: left;
flex-grow: 0;
}
.fa {
align-self: center;
padding: 10px;
}
.venue-content{
background: #a3a3a3;
width: 100%
}
h4{
display: inline-flex;
}
.competitor-name {
padding: 4px;
}
ul li{
padding: 5px 10px;
border: 1px solid #808080;
}
Here is a start, where I moved the ft-container inside the header, positioned before the venue-content.
Then, by splitting the ul into to 2 ul, you can easily line them up side-by-side, adding display: flex to the ft-container.
Updated fiddle
Stack snippet
body {
font-size: 12px;
}
.game-heading {
background: #a3a3a3;
}
header {
display: flex;
}
article {
display: flex;
}
.scores {
display: flex;
flex-wrap: wrap;
flex: 1;
line-height: 1;
}
.period {
background: #c29d31;
padding: 5px 10px;
text-align: center;
}
.results {
display: flex;
flex-direction: column;
}
.score-nr {
background: #9E8231;
flex: 1;
line-height: 10px;
padding: 6px;
}
.competitors {
color: #2d2929;
flex-direction: row;
align-items: flex-start;
float: left;
flex-grow: 1;
}
.fa {
align-self: center;
padding: 10px;
}
.venue-content {
background: #a3a3a3;
width: 100%
}
h4 {
display: inline-flex;
}
.competitor-name {
padding: 4px;
}
/* styles below have been changed/added */
ul li {
padding: 5px 10px;
}
ul {
border: 1px solid #808080;
}
.ft-container {
display: flex;
}
.ft-container ul:last-child {
display: flex;
align-items: center;
}
<link href="https://cdnjs.cloudflare.com/ajax/libs/meyer-reset/2.0/reset.css" rel="stylesheet"/>
<link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.css" rel="stylesheet"/>
<section class="container-one-row two">
<h3 class="game-heading">game type </h3>
<article class="game-content">
<header class="event-title">
<div class="scores">
<span class="period">Time</span>
<div class="results">
<span class="score-nr">5122</span>
<span class="score-nr">8213</span>
</div>
<div class="competitors">
<h3 class="competitor-name">jimmy1234</h3>
<h3 class="competitor-name">player98763</h3>
</div>
<i class="fa fa-arrow-right"></i>
<section class="ft-container">
<ul>
<li>222
</li>
<li>543
</li>
</ul>
<ul>
<li>mid
</li>
</ul>
</section>
<div class="venue-content">
<h4>Neutral</h4>
<i class=" fa fa-gamepad"></i>
</div>
</div>
</header>
</article>
</section>
Updated based on a comment saying, can't move the ft-container's markup
Then you needed to use absolute positioning, to position the ft-container at the right, and match its height against the competitors, which in itself need to match the ft-container and arrow to avoid a wrap.
Updated fiddle
Stack snippet
body {
font-size: 12px;
}
.game-heading {
background: #a3a3a3;
}
header {
display: flex;
flex: 1;
}
article {
position: relative;
display: flex;
}
.scores {
display: flex;
flex-wrap: wrap;
flex: 1;
line-height: 1;
}
.period {
background: #c29d31;
padding: 5px 10px;
text-align: center;
}
.results {
display: flex;
flex-direction: column;
}
.score-nr {
background: #9E8231;
flex: 1;
line-height: 10px;
padding: 6px;
}
.competitors {
color: #2d2929;
flex-direction: row;
align-items: flex-start;
width: calc(100% - 200px);
}
.fa {
align-self: center;
padding: 10px;
}
.venue-content {
background: #a3a3a3;
width: 100%;
}
h4 {
display: inline-flex;
}
.competitor-name {
padding: 4px;
}
ul li {
padding: 5px 10px;
}
ul {
border: 1px solid #808080;
}
.ft-container {
position: absolute;
right: 0;
top: 0;
height: 44px;
display: flex;
}
.ft-container ul:last-child {
display: flex;
align-items: center;
}
<link href="https://cdnjs.cloudflare.com/ajax/libs/meyer-reset/2.0/reset.css" rel="stylesheet"/>
<link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.css" rel="stylesheet"/>
<section class="container-one-row two">
<h3 class="game-heading">game type </h3>
<article class="game-content">
<header class="event-title">
<div class="scores">
<span class="period">Time</span>
<div class="results">
<span class="score-nr">5122</span>
<span class="score-nr">8213</span>
</div>
<div class="competitors">
<h3 class="competitor-name">jimmy1234</h3>
<h3 class="competitor-name">player98763</h3>
</div>
<i class="fa fa-arrow-right"></i>
<div class="venue-content">
<h4>Neutral</h4>
<i class=" fa fa-gamepad"></i>
</div>
</div>
</header>
<section class="ft-container">
<ul>
<li>222
</li>
<li>543
</li>
</ul>
<ul>
<li>mid
</li>
</ul>
</section>
</article>
</section>
Related
This question already has answers here:
Fill remaining vertical space with CSS using display:flex
(6 answers)
Closed 9 months ago.
I'm trying to expand the content in the middle (main-box) to fit the whole page until it reaches the footer.
I've tried adding flex: 1 to it, making the height: 100% or even use flex-grow: 1 as it is a child of a flex item.
body {
display: flex;
flex: 1;
flex-direction: column;
border: solid black 10px;
}
.page {
display: flex;
flex-direction: column;
flex: 1;
}
header {
background-color: #2D3047;
color: #E0CA3C;
}
.container {
flex-grow: 1;
}
.buttons {
text-align: center;
}
.points {
display: flex;
justify-content: center;
gap: 10px;
}
.computer,
.player {
border: solid black 2px;
padding: 10px;
margin: 20px;
}
.result {
text-align: center;
border: solid black 2px;
margin: 0;
padding: 0;
width: auto;
}
footer {
background-color: #2D3047;
color: #E0CA3C;
justify-self: flex-end;
}
<div class="page">
<header>
<h1>Rock, Paper, Scissors</h1>
</header>
<div class="main-box">
<div class="buttons">
<button class="rock">Rock</button>
<button class="paper">Paper</button>
<button class="scissors">Scissors</button>
</div>
<div class="container">
<div class="points">
<div class="player-score">0</div>
<div class="computer-score">0</div>
</div>
<div class="result"></div>
</div>
</div>
<div class="footer">Copyright CAIFRA</div>
</div>
Codepen
I see you are using position absolute on footer class , in my opinion take a look i change it into a position relative. using position relative with bottom 0 , then it will work,
<div class="page">
<header>
<h1>Rock, Paper, Scissors</h1>
</header>
<div class="main-box">
<div class="buttons">
<button class="rock">Rock</button>
<button class="paper">Paper</button>
<button class="scissors">Scissors</button>
</div>
<div class="container">
<div class="points">
<div class="player-score">0</div>
<div class="computer-score">0</div>
</div>
<div class="result"></div>
</div>
</div>
<div class="footer">
Copyright CAIFRA
</div>
</div>
CSS CODE
body {
margin: 0;
padding: 0;
}
header {
text-align: center;
background-color: #2D3047;
color: #E0CA3C;
padding: 20px;
}
.page {
display: flex;
flex-direction: column;
flex: 1;
}
.main-box {
background-color: #93B7BE;
display: flex;
flex-direction: column;
justify-content: center;
flex-grow: 1;
}
.computer-score, .player-score {
border: 2px black solid;
width: 50px;
height: 50px;
display: flex;
justify-content: center;
align-items: center;
margin: 20px;
}
.points {
display: flex;
flex-direction: row;
align-items: center;
justify-content: center;
}
.result {
border: 2px black solid;
height: 50px;
width: 300px;
margin-left: auto;
margin-bottom: 20px;
margin-right: auto;
display: flex;
align-items: center;
justify-content: center;
}
.buttons {
display: flex;
align-items: center;
justify-content: center;
gap: 20px;
padding-top: 30px;
}
.footer {
text-align: center;
background-color: #2D3047;
color: #E0CA3C;
padding: 10px;
position: relative;
bottom: 0;
left: 0;
width: 100%;
}
Maybe you can add 100vh on your container and see if this is what you want. Let me know
html {height: 99.1%;}
body {
flex-direction: column;
border: 10px solid black ;
height:99.1%;
margin: 0;
padding: 0;
}
.page {
display: flex;
flex-direction: column;
}
header {
background-color: #2D3047;
color: #E0CA3C;
}
.container {
height: 99.1% ;
bottom: 10px;
overflow: hidden;
}
.buttons {
text-align: center;
}
.points {
display: flex;
justify-content: center;
gap: 10px;
}
.computer,
.player {
border: solid black 2px;
padding: 10px;
margin: 20px;
}
.result {
text-align: center;
border: solid black 2px;
margin: 0;
padding: 0;
width: auto;
}
.footer {
background-color: #2D3047;
color: #E0CA3C;
bottom: 10px;
position: fixed;
width: 100%;
}
<body>
<div class="page">
<header>
<h1>Rock, Paper, Scissors</h1>
</header>
<div class="main-box">
<div class="buttons">
<button class="rock">Rock</button>
<button class="paper">Paper</button>
<button class="scissors">Scissors</button>
</div>
<div class="container">
<div class="points">
<div class="player-score">0</div>
<div class="computer-score">0</div>
</div>
<div class="result"></div>
</div>
</div>
<div class="footer">Copyright CAIFRA</div>
</div>
</body>
body {
margin: 0;
padding: 0;
}
header {
text-align: center;
background-color: #2D3047;
color: #E0CA3C;
padding: 20px;
}
.page {
display: flex;
flex-direction: column;
height: 90vh;
}
.main-box {
background-color: #93B7BE;
display: flex;
flex-direction: column;
justify-content: center;
flex-grow: 1;
height: 100vh;
}
.computer-score,
.player-score {
border: 2px black solid;
width: 50px;
height: 50px;
display: flex;
justify-content: center;
align-items: center;
margin: 20px;
}
.points {
display: flex;
flex-direction: row;
align-items: center;
justify-content: center;
}
.result {
border: 2px black solid;
height: 50px;
width: 300px;
margin-left: auto;
margin-bottom: 20px;
margin-right: auto;
display: flex;
align-items: center;
justify-content: center;
}
.buttons {
display: flex;
align-items: center;
justify-content: center;
gap: 20px;
padding-top: 30px;
}
.footer {
text-align: center;
background-color: #2D3047;
color: #E0CA3C;
padding: 10px;
position: absolute;
bottom: 0;
left: 0;
width: 100%;
}
<div class="page">
<header>
<h1>Rock, Paper, Scissors</h1>
</header>
<div class="main-box">
<div class="buttons">
<button class="rock">Rock</button>
<button class="paper">Paper</button>
<button class="scissors">Scissors</button>
</div>
<div class="container">
<div class="points">
<div class="player-score">0</div>
<div class="computer-score">0</div>
</div>
<div class="result"></div>
</div>
<div class="footer">
Copyright CAIFRA
</div>
</div>
</div>
Simply add body { min-height: 100vh; }, so it actually ahs the size of at least the viewport size. By default it will only have the height of the content.
body {
margin: 0;
box-sizing: border-box;
min-height: 100vh;
}
/* original CSS */
body {
display: flex;
flex-direction: column;
border: solid black 10px;
}
.page {
display: flex;
flex-direction: column;
}
header {
background-color: #2D3047;
color: #E0CA3C;
}
.container {
flex-grow: 1;
}
.buttons {
text-align: center;
}
.points {
display: flex;
justify-content: center;
gap: 10px;
}
.computer,
.player {
border: solid black 2px;
padding: 10px;
margin: 20px;
}
.result {
text-align: center;
border: solid black 2px;
margin: 0;
padding: 0;
width: auto;
}
footer {
background-color: #2D3047;
color: #E0CA3C;
}
<div class="page">
<header>
<h1>Rock, Paper, Scissors</h1>
</header>
<div class="main-box">
<div class="buttons">
<button class="rock">Rock</button>
<button class="paper">Paper</button>
<button class="scissors">Scissors</button>
</div>
<div class="container">
<div class="points">
<div class="player-score">0</div>
<div class="computer-score">0</div>
</div>
<div class="result"></div>
</div>
</div>
<div class="footer">Copyright CAIFRA</div>
</div>
Hi guys I can't seem to center my button within the flexbox container class="hero". Any ideas why this is?
the button is below the email form but is left aligned to it (start in the same position).
I am trying to center the button like the example on this link:https://codepen.io/freeCodeCamp/full/RKRbwL. My CSS code also has a CSS reset but I haven't pasted that in. Thanks!
* {
box-sizing: border-box;
}
body {
font-family: "Roboto", sans-serif;
min-height: 100vh;
background-color: #eee;
color: black;
}
nav {
display: flex;
flex-direction: row;
justify-content: space-around;
align-items: center;
font-weight: 900;
font-size: 1em;
padding: 20px 10px;
flex-wrap: wrap;
border-bottom: 1px solid grey;
position: sticky;
}
ul {
flex-grow: 1;
max-width: 30%;
display: flex;
justify-content: space-around;
text-decoration: none;
}
img {
display: flex;
width: 40vw;
}
ul li {
display: inline;
text-decoration: none;
display: flex;
}
.nav-links a {
text-decoration: none;
color: black;
}
.hero {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
}
h1 {
font-size: 2em;
font-weight: 700;
padding: 20px;
}
input[type="email"] {
padding: 5px 10px;
margin: 10px 0px;
border: solid 1px black;
width: 350px;
}
input[type="submit"] {}
#media (max-width: 700px) {
header {
font-size: 1em;
}
nav {
display: flex;
flex-direction: column;
}
ul {
display: flex;
flex-wrap: wrap;
}
}
<html>
<body>
<header>
<nav class="Navbar">
<img src="https://cdn.freecodecamp.org/testable-projects-fcc/images/product-landing-page-logo.png" alt="original trombones logo" class="nav-img">
<ul class="nav-links">
<li>Features</li>
<li>How It Works</li>
<li>Pricing</li>
</ul>
</nav>
</header>
<section class="hero">
<h1>Handcrafted, home-made masterpieces</h1>
<form class="email-form">
<div class="email-form">
<label for="email"></label>
<input type="email" name="email" id="email" placeholder="Enter your email address" required>
</div>
<div class="button-center">
<input class="sub-button" type="submit" value="GET STARTED">
</div>
</form>
</section>
</body>
</html>
For a flex solution, you have some options. It truly just depends on the extent of your design. Here are a few:
.button-center {
display: flex;
justify-content: center;
/* text-align: center; ~ non-flex solution */
}
form.email-form {
display: flex;
flex-direction: column;
align-items: center;
}
See it working here:
* {
box-sizing: border-box;
}
body {
font-family: "Roboto", sans-serif;
min-height: 100vh;
background-color: #eee;
color: black;
}
.button-center {
display: flex;
justify-content: center;
/*text-align: center;*/
}
form.email-form {
display: flex;
flex-direction: column;
align-items: center;
}
nav {
display: flex;
flex-direction: row;
justify-content: space-around;
align-items: center;
font-weight: 900;
font-size: 1em;
padding: 20px 10px;
flex-wrap: wrap;
border-bottom: 1px solid grey;
position: sticky;
}
ul {
flex-grow: 1;
max-width: 30%;
display: flex;
justify-content: space-around;
text-decoration: none;
}
img {
display: flex;
width: 40vw;
}
ul li {
display: inline;
text-decoration: none;
display: flex;
}
.nav-links a {
text-decoration: none;
color: black;
}
.hero {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
}
h1 {
font-size: 2em;
font-weight: 700;
padding: 20px;
}
input[type="email"] {
padding: 5px 10px;
margin: 10px 0px;
border: solid 1px black;
width: 350px;
}
input[type="submit"] {}
#media (max-width: 700px) {
header {
font-size: 1em;
}
nav {
display: flex;
flex-direction: column;
}
ul {
display: flex;
flex-wrap: wrap;
}
}
<html>
<body>
<header>
<nav class="Navbar">
<img src="https://cdn.freecodecamp.org/testable-projects-fcc/images/product-landing-page-logo.png" alt="original trombones logo" class="nav-img">
<ul class="nav-links">
<li>Features</li>
<li>How It Works</li>
<li>Pricing</li>
</ul>
</nav>
</header>
<section class="hero">
<h1>Handcrafted, home-made masterpieces</h1>
<form class="email-form">
<div class="email-form">
<label for="email"></label>
<input type="email" name="email" id="email" placeholder="Enter your email address" required>
</div>
<div class="button-center">
<input class="sub-button" type="submit" value="GET STARTED">
</div>
</form>
</section>
</body>
</html>
Just add
.button-center { text-align: center}
Your container is centered, but is full width, so the button goes to the left, adding the code above, will center the button.
I have a JS fiddle here and it's pretty simple what I want to happen but difficult for me to execute it. In the fiddle, you notice there is a red box. I want that red box to be displayed under the text "Join Balance...". I am not sure how to do this.
Can somebody help me?
Fiddle: https://jsfiddle.net/f2h390wc/
HTML and CSS:
/* newsletter section */
#custom_html-5 {
width: 100%;
background-color: #f2f2f2;
padding-bottom: 40px;
padding-top: 20px;
margin-bottom: 70px;
padding-left: 70px !important;
padding-right: 20px !important;
}
.newsletter_inner_section {
display: flex;
}
.newsletter_gif {
width: 200px;
height: auto;
}
.newsletter_left,
.newsletter_center,
.newsletter_right {
display: inline-flex;
}
.newsletter_left {
width: auto;
}
.newsletter_center {
width: 100%;
align-items: center;
}
.newsletter_right {
background: red;
width: 40%;
justify-content: flex-end;
}
.newsletter_text_section {
color: black !important;
font-size: 24px !important;
font-weight: bold;
}
.eVEmvD.eVEmvD.eVEmvD.eVEmvD.eVEmvD.eVEmvD {
width: fit-content !important;
padding: 0 20px;
}
.fGCWnQ.fGCWnQ {
justify-content: flex-end;
}
.kvTDNe.kvTDNe {
display: unset;
}
/* Media Newsletter section only */
#media (max-width:1144px) {
#custom_html-5 {
padding-left: 20px !important;
padding-right: 20px !important;
}
.newsletter_inner_section {
width: 100% !important;
justify-content: center;
display: flex;
}
.newsletter_center,
.newsltter_right {
flex-direction: column !important;
}
}
<!-- newsletter section -->
<div class="newsletter_section">
<div class="newsletter_inner_section">
<div class="newsletter_left">
<img src="https://balancecoffee.co.uk/wp-content/themes/balancecoffeechild/img/newsletternnobkg2.gif" alt="Balance Newsletter" style="padding-right:30px;" class="newsletter_gif">
</div>
<div class="newsletter_center">
<p class="newsletter_text_section">Join Balance and get 20% off your first order</p>
</div>
<div class="newsletter_right">
<div class="newsletter_input_section">
<div class="klaviyo-form-Rrsqsh"></div>
</div>
</div>
</div>
</div>
If you want the text and the red box on the right to form a column, then they both need to be in a flexbox with flex-direction: column;.
I created a sample from scratch because there is a lot of superfluous stuff in your JSFiddle.
.group {
display: flex;
flex-direction: row;
width: 100%;
}
.content-box {
display: flex;
flex-direction: column;
justify-content: center;
align-content: center;
padding: 40px;
}
.left {
background-color: blue;
}
.right {
flex-grow: 1;
display: flex;
flex-direction: column;
}
.top-right {
background-color: green;
}
.bottom-right {
background-color: red;
}
<div class='group'>
<div class='left content-box'>
Content
</div>
<div class='right'>
<div class='top-right content-box'>
Content
</div>
<div class='bottom-right content-box'>
Content
</div>
</div>
</div>
https://www.w3schools.com/cssref/css3_pr_flex-direction.asp
display: flex;
flex-direction: column;
So basically I am trying to create nice splash page and the designer wants the links diagonal, circular, and all the same size, the <p>'s are gonna be links, but how can I make them all diagonal and all the same size circle?
I have tried a lot of different flexbox combinations I haven't tried CSS grid yet, that is going to be what I try next.
/*variable declarations*/
:root {
--teal: #37C8AB;
--white: #ffffff;
--black: #000000;
--lilac: #B380FF;
--purple: #7137C8;
--aqua: #008066;
}
/*page body*/
body {
box-sizing: border-box;
margin: 0;
padding: 0;
}
.page-container {
background: var(--lilac);
margin-top: 10px;
padding-bottom: 5em;
padding-left: 2em;
padding-top: 5.8em;
}
/*Text Conatiner*/
.tcontainer-frame {
background: var(--purple);
border: var(--black) 2px solid;
display: flex;
justify-content: center;
align-items: center;
padding: 1em;
}
.tcontainer {
background: var(--black);
font-size: 24px;
padding: 12em 1em;
text-align: center;
}
.teal-font {
color: var(--teal);
}
/*Link container*/
.link-container {
display: flex;
flex-flow: column wrap;
padding: 4em;
text-align: center;
}
#newSolCircle {
align-items: center;
align-self: flex-start;
background: var(--teal);
border-radius: 100%;
display: flex;
flex: 1 1 0;
justify-content: center;
margin: 2em;
padding: 1em;
}
#patronCircle {
align-items: center;
align-self: center;
background: var(--aqua);
border-radius: 100%;
display: flex;
flex: 1 1 0;
margin: 2em;
padding: 1em;
}
#alchemistCircle {
align-items: center;
align-self: flex-end;
background: var(--purple);
border-radius: 100%;
display: flex;
flex: 1 1 0;
margin: 2em;
padding: 1em;
}
<body class="bg-dark">
<div class="container-fluid page-container">
<div class="row">
<div class="col-6 tcontainer-frame">
<div class="tcontainer"><span class="teal-font">Hello. You have landed on the Image Alchemists' web portal. We
welcome
you. Please make your
selection to the right.</span>
</div>
</div>
<div class="col-6 link-container">
<div id="newSolCircle">
<p>New Solicitor</p>
</div>
<div id="patronCircle">
<p>Patron</p>
</div>
<div id="alchemistCircle">
<p>Alchemist</p>
</div>
</div>
</div>
</div>
</body>
I am just hoping to get those 3 circles to all line up correctly and have them all be the same width and height. Thanks in advance for anyone's help.
Including width and height was necessary to make them of the same size and in circle shape.
Then i removed flex: 1 1 0; as the align-items property alone was solving the problem along with the width and height.
:root {
--teal: #37C8AB;
--white: #ffffff;
--black: #000000;
--lilac: #B380FF;
--purple: #7137C8;
--aqua: #008066;
}
/*page body*/
body {
box-sizing: border-box;
margin: 0;
padding: 0;
}
.page-container {
background: var(--lilac);
margin-top: 10px;
padding-bottom: 5em;
padding-left: 2em;
padding-top: 5.8em;
}
/*Text Conatiner*/
.tcontainer-frame {
background: var(--purple);
border: var(--black) 2px solid;
display: flex;
justify-content: center;
align-items: center;
padding: 1em;
}
.tcontainer {
background: var(--black);
font-size: 24px;
padding: 12em 1em;
text-align: center;
}
.teal-font {
color: var(--teal);
}
/*Link container*/
.link-container {
display: flex;
flex-flow: column wrap;
padding: 4em;
text-align: center;
}
.circle {
border-radius: 100%;
display: flex;
height: 50px;
width: 50px;
margin: 2em;
padding: 1em;
justify-content: center;
}
#newSolCircle {
align-items: center;
align-self: flex-start;
background: var(--teal);
}
#patronCircle {
align-items: center;
align-self: center;
background: var(--aqua);
}
#alchemistCircle {
align-items: center;
align-self: flex-end;
background: var(--purple);
}
<body class="bg-dark">
<div class="container-fluid page-container">
<div class="row">
<div class="col-6 tcontainer-frame">
<div class="tcontainer"><span class="teal-font">Hello. You have landed on the Image Alchemists' web portal. We
welcome
you. Please make your
selection to the right.</span>
</div>
</div>
<div class="col-6 link-container">
<div id="newSolCircle" class="circle">
<p>New Solicitor</p>
</div>
<div id="patronCircle" class="circle">
<p>Patron</p>
</div>
<div id="alchemistCircle" class="circle">
<p>Alchemist</p>
</div>
</div>
</div>
</div>
</div>
</body>
Try this
/*variable declarations*/
:root {
--teal: #37C8AB;
--white: #ffffff;
--black: #000000;
--lilac: #B380FF;
--purple: #7137C8;
--aqua: #008066;
}
/*page body*/
body {
box-sizing: border-box;
margin: 0;
padding: 0;
}
.page-container {
background: var(--lilac);
margin-top: 10px;
padding-bottom: 5em;
padding-left: 2em;
padding-top: 5.8em;
}
/*Text Conatiner*/
.tcontainer-frame {
background: var(--purple);
border: var(--black) 2px solid;
display: flex;
justify-content: center;
align-items: center;
padding: 1em;
}
.tcontainer {
background: var(--black);
font-size: 24px;
padding: 12em 1em;
text-align: center;
}
.teal-font {
color: var(--teal);
}
/*Link container*/
.link-container {
display: flex;
flex-flow: column wrap;
padding: 4em;
text-align: center;
}
.circle {
align-items: center;
align-self: flex-start;
background: var(--teal);
border-radius: 100%;
display: flex;
/* flex: 1 1 0; */
justify-content: center;
/* margin: 2em;
padding: 1em; */
height: 150px;
width: 150px;
}
#newSolCircle {
display: flex;
justify-content: flex-start;
}
#patronCircle {
display: flex;
justify-content: center;
}
#patronCircle .circle {
background: var(--aqua);
}
#alchemistCircle {
display: flex;
justify-content: flex-end;
}
#alchemistCircle .circle {
background: var(--purple);
}
<body class="bg-dark">
<div class="container-fluid page-container">
<div class="row">
<div class="col-6 tcontainer-frame">
<div class="tcontainer"><span class="teal-font">Hello. You have landed on the Image Alchemists' web portal. We
welcome
you. Please make your
selection to the right.</span>
</div>
</div>
<div class="col-6">
<div class="link-container">
<div id="newSolCircle">
<p class="circle">New Solicitor</p>
</div>
<div id="patronCircle">
<p class="circle">Patron</p>
</div>
<div id="alchemistCircle">
<p class="circle">Alchemist</p>
</div>
</div>
</div>
</div>
</div>
</body>
I'm trying to create a scrolling element without a fixed height parent. I want #SECTION1 of my code to be scrollable to show the rest of the images. I can't seem to find a way to do this. I've attempted to set #SECTION1 to a fixed height but it forces my images to be squashed. Any help would be appreciated. Thank you.
Here is my code:
* {
box-sizing: border-box;
margin: 0;
padding: 0;
text-decoration: none;
}
::-webkit-scrollbar {
width: 15px;
}
/* Track */
::-webkit-scrollbar-track {
background: #f1f1f1;
}
/* Handle */
::-webkit-scrollbar-thumb {
background: #888;
}
/* Handle on hover */
::-webkit-scrollbar-thumb:hover {
background: #555;
}
html,
body {
margin: 0;
padding: 0;
height: 100vh;
overflow: hidden;
}
/*----------SECTION 1----------*/
header {
height: 80px;
background-color: black;
display: flex;
justify-content: center;
align-items: center;
width: 100%;
}
#header-wrapper {
display: flex;
width: 55%;
justify-content: space-between;
align-items: center;
}
#logo {
width: 70px;
}
nav a {
color: white;
padding: 20px;
font-family: 'Roboto';
font-size: 0.8em;
font-weight: bold;
}
#media only screen and (max-width: 750px) {
nav {
display: none;
}
}
#mobile-menu {
color: white;
font-size: 1.3em;
}
#media only screen and (min-width: 750px) {
#mobile-menu {
display: none;
}
}
#body-wrapper {
display: flex;
height: 100%;
}
aside {
width: 300px;
height: 889px;
background-color: #0c0c0c;
display: flex;
align-items: center;
padding-top: 50px;
flex-direction: column;
}
#aside-wrap {
width: 70%;
}
#user-info {
display: flex;
margin: 10px;
margin-left: 0;
margin-bottom: 50px;
justify-content: center;
align-items: center;
font-family: 'Roboto';
font-weight: 400;
}
#user {
font-size: 40px;
color: white;
margin-right: 20px;
}
aside h3 {
color: white;
font-size: 1.2em;
}
#hello {
color: white;
font-size: 20px;
}
#box-1 {
color: #808080;
margin-bottom: 60px;
}
#box-1 p {
margin: 20px;
margin-left: 0;
font-family: 'Roboto';
font-size: 0.9em;
}
#box-2 {
color: #808080;
}
#box-2 p {
margin: 20px;
margin-left: 0;
font-family: 'Roboto';
font-size: 0.9em;
}
#section1 {
background-color: #191919;
/*background: linear-gradient(rgba(0,0,0,0.3),rgba(0,0,0,0.3)),
url("listen_background.jpg");*/
display: flex;
align-items: center;
justify-content: center;
flex-direction: column;
width: 100%;
overflow: auto;
}
#section1-wrapper {
width: 80%;
display: flex;
font-family: 'Roboto';
padding-top: 50px;
padding-bottom: 50px;
align-items: center;
flex-direction: column;
}
#section1 h1 {
color: white;
font-size: 3em;
margin-bottom: 50px;
text-align: center;
}
.image-box {
max-width: 280px;
margin: 20px;
}
img {
max-width: 100%;
}
#image-row-1,
#image-row-2,
#image-row-3,
#image-row-4 {
width: 100%;
margin-bottom: 50px;
display: flex;
justify-content: space-between;
}
#media only screen and (max-width: 1080px) {
#image-row-1,
#image-row-2,
#image-row-3,
#image-row-4 {
flex-direction: column;
align-items: center;
}
}
/*----------------SECTION 2--------------*/
#pusher {
height: 889px;
width: 300px;
}
#player {
height: 80px;
width: 100%;
position: fixed;
bottom: 0;
display: flex;
justify-content: center;
align-items: center;
background-color: black;
}
#media only screen and (max-width: 750px) {
#player {
height: auto;
}
}
#player-wrapper {
display: flex;
justify-content: space-between;
align-items: center;
width: 80%;
}
#media only screen and (max-width: 750px) {
#player-wrapper {
flex-direction: column;
}
}
.button-controls {
color: white;
margin: 20px;
}
#player-bar {
width: 100%;
height: 3px;
background-color: white;
}
#player-filler {
width: 50%;
height: 100%;
background-color: #2A4B5A;
}
#timeline {
width: 50%;
display: flex;
justify-content: center;
align-items: center;
}
#media only screen and (max-width: 750px) {
#timeline {
width: 100%;
}
}
#timeline p {
color: white;
margin: 20px;
}
#share,
#phone {
color: white;
margin: 20px;
}
#media only screen and (max-width: 750px) {
#share,
#phone {
display: none;
}
}
<head>
<meta charset="utf-8">
<title>Flo Music</title>
<link rel="stylesheet" type="text/css" href="listen.css">
<link href="https://fonts.googleapis.com/css?family=Roboto:300,400,500,700" rel="stylesheet">
<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.5.0/css/all.css" integrity="sha384-B4dIYHKNBt8Bc12p+WXckhzcICo0wtJAoU8YZTY5qE0Id1GSseTk6S+L3BlXeVIU" crossorigin="anonymous">
</head>
<body>
<div id="test">
<div id="body-wrapper">
<aside>
<div id="aside-wrap">
<div id="user-info">
<i class="far fa-user-circle" id="user"></i>
<h3>Emmanuel</h3>
</div>
<div id="box-1">
<p>Your Library</p>
<p>Recently Played</p>
<p>Songs</p>
<p>Playlist</p>
</div>
<div id="box-2">
<p>Your Library</p>
<p>Recently Played</p>
<p>Songs</p>
<p>Playlist</p>
</div>
<p>HOME</p>
</div>
</aside>
<section id="section1">
<div id="section1-wrapper">
<h1>New Releases</h1>
<div id="image-row-1">
<div class="image-box"><img src="album1.jpg"></div>
<div class="image-box"><img src="album2.jpg"></div>
<div class="image-box"><img src="album3.jpg"></div>
<div class="image-box"><img src="album4.jpg"></div>
</div>
<div id="image-row-2">
<div class="image-box"><img src="album5.jpg"></div>
<div class="image-box"><img src="album6.jpg"></div>
<div class="image-box"><img src="album7.jpg"></div>
<div class="image-box"><img src="album8.png"></div>
</div>
<div id="image-row-3">
<div class="image-box"><img src="album9.jpg"></div>
<div class="image-box"><img src="album10.jpg"></div>
<div class="image-box"><img src="album11.jpg"></div>
<div class="image-box"><img src="album12.jpg"></div>
</div>
<div id="image-row-4">
<div class="image-box"><img src="album13.jpg"></div>
<div class="image-box"><img src="album14.jpg"></div>
<div class="image-box"><img src="album15.jpg"></div>
<div class="image-box"><img src="album16.jpg"></div>
</div>
</div>
</section>
</div>
<div id="player">
<div id="player-wrapper">
<div id="controls">
<i class="fas fa-backward button-controls"></i>
<i class="fas fa-play button-controls"></i>
<i class="fas fa-forward button-controls"></i>
</div>
<div id="timeline">
<p>0:00</p>
<div id="player-bar">
<div id="player-filler"></div>
</div>
<p>0:00</p>
</div>
<div id="icon-right">
<i class="fas fa-share-square" id="share"></i>
<i class="fas fa-mobile" id="phone"></i>
</div>
Flex items are set to flex-shrink: 1 by default. This means they can shrink to prevent an overflow of the container. In your case, you may need to disable this feature (flex-shrink: 0).
Also, consider using height: 100vh, instead of height: 100% on your flex container. Percentage heights are tricky and often require the parent to have a defined height.
See this post for details: Working with the CSS height property and percentage values
Lastly, remove justify-content: center from your flex container. It makes content inaccessible via scroll in some cases.
See this post for details: Can't scroll to top of flex item that is overflowing container
Make these adjustments to your code:
#body-wrapper {
display: flex;
/* height: 100%; */
height: calc(100vh - 80px); /* subtract footer height */
}
#section1 {
background-color: #191919;
display: flex;
align-items: center;
/* justify-content: center; */ /* remove to avoid scrolling problems */
flex-direction: column;
width: 100%;
overflow: auto;
}
#section1-wrapper {
width: 80%;
display: flex;
font-family: 'Roboto';
padding-top: 50px;
padding-bottom: 50px;
align-items: center;
flex-direction: column;
flex-shrink: 0; /* add to disable flex default shrinking feature */
}
jsFiddle demo
You should change your overflow property in the #section1
#section1-wrapper {
overflow: scroll;
}