Welcome!

By registering with us, you'll be able to discuss, share and private message with other members of our community.

SignUp Now!
  • Guest, before posting your code please take these rules into consideration:
    • It is required to use our BBCode feature to display your code. While within the editor click < / > or >_ and place your code within the BB Code prompt. This helps others with finding a solution by making it easier to read and easier to copy.
    • You can also use markdown to share your code. When using markdown your code will be automatically converted to BBCode. For help with markdown check out the markdown guide.
    • Don't share a wall of code. All we want is the problem area, the code related to your issue.


    To learn more about how to use our BBCode feature, please click here.

    Thank you, Code Forum.

HTML & CSS Why is align-content not working...

Chris

Coder
....while justify-content does??

Hi,

Please take a look at this.

I know, this example is not made to show how align-content works, even though I think it should work.

So I tried this:

CSS:
#main {
    width: 400px;
    height: 100px;
    border: 1px solid #c3c3c3;
    display: flex;
    justify-content: center;
    align-content: center;
}

but nothing happens...

(I would expect the three boxes to move slightly down as there is still a bit space.)

Can anybody tell me why?

Best wishes,

Chris
 
Last edited by a moderator:
Solution
Hey there,

Have you tried it without "Align-content"? And if you can, can you share all your code?
Meanwhile I found the solution: There is no align-content for flexbox. It only works with align-items:

HTML:
<!DOCTYPE html>
<html>
<head>
<style>
#main {
  width: 400px;
  height: 100px;
  border: 1px solid #c3c3c3;
  display: flex;
  justify-content: center;
  align-items: center;
}

#main div {
  width: 70px;
  height: 70px;
}
</style>
</head>
<body>

<h1>The justify-content Property</h1>

<p>The "justify-content: center;" aligns the flex items at the center of the container:</p>

<div id="main">
  <div style="background-color:coral;">1</div>
  <div style="background-color:lightblue;">2</div>
  <div...
....while justify-content does??

Hi,

Please take a look at this.

I know, this example is not made to show how
CSS:
align-content
works, even though I think it should work.

So I tried this:

Code:
#main {
    width: 400px;
    height: 100px;
    border: 1px solid #c3c3c3;
    display: flex;
    justify-content: center;
    align-content: center;
}

but nothing happens...

(I would expect the three boxes to move slightly down as there is still a bit space.)

Can anybody tell me why?

Best wishes,

Chris
Hey there,

Have you tried it without "Align-content"? And if you can, can you share all your code?
 
Hey there,

Have you tried it without "Align-content"? And if you can, can you share all your code?
Meanwhile I found the solution: There is no align-content for flexbox. It only works with align-items:

HTML:
<!DOCTYPE html>
<html>
<head>
<style>
#main {
  width: 400px;
  height: 100px;
  border: 1px solid #c3c3c3;
  display: flex;
  justify-content: center;
  align-items: center;
}

#main div {
  width: 70px;
  height: 70px;
}
</style>
</head>
<body>

<h1>The justify-content Property</h1>

<p>The "justify-content: center;" aligns the flex items at the center of the container:</p>

<div id="main">
  <div style="background-color:coral;">1</div>
  <div style="background-color:lightblue;">2</div>
  <div style="background-color:pink;">3</div>
</div>

<p><b>Note:</b> Internet Explorer 10 and earlier versions do not support the justify-content property.</p>

</body>
</html>
 
Solution

New Threads

Latest posts

Buy us a coffee!

Back
Top Bottom