I'm a newbie in CSS Grid, after searching in Google, I haven't found what I seek for, I wonder in alignment and justifying properties, what is the difference between flex-start/flex-end and start/end value please?
no difference
flex-start
For items that are not children of a flex container, this value is treated like start
.
https://developer.mozilla.org/en-US/docs/Web/CSS/justify-content#values
On my experience:
- flex-start and flex-end target Flexboxs items specifically.
- start and end target other items.
Here the doc:
/* Positional alignment */
justify-content: center; /* Pack items around the center */
justify-content: start; /* Pack items from the start */
justify-content: end; /* Pack items from the end */
justify-content: flex-start; /* Pack flex items from the start */
justify-content: flex-end; /* Pack flex items from the end */
justify-content: left; /* Pack items from the left */
justify-content: right; /* Pack items from the right */
no difference
flex-start
For items that are not children of a flex container, this value is treated like start
.
https://developer.mozilla.org/en-US/docs/Web/CSS/justify-content#values
I recommend you to try out this game. It will give you enough practice for Flexbox. Now, there are 2 properties which use flex-start/flex-end.
- justify-content:The justify-content property aligns the flexible container's items when the items do not use all available space on the main-axis (horizontally). It means justify-content helps to align content horizontally.
- align-items: The align-items property specifies the default alignment for items inside the flexible container. It means align-items helps to align content vertically.
flex-start and flex-end for justify-content means start and end (horizontally) of any container.
<!DOCTYPE html>
<html>
<head>
<style>
#main {
width: 400px;
height: 100px;
border: 1px solid #c3c3c3;
display: -webkit-flex; /* Safari */
-webkit-justify-content: flex-start; /* Safari 6.1+ */
display: flex;
justify-content: flex-start;
}
#main div {
width: 70px;
height: 70px;
}
</style>
</head>
<body>
<h1>The justify-content Property</h1>
<p>The "justify-content: flex-start;" aligns the flex items at the beginning of the container (this is default):</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>
<p><b>Note:</b> Safari 6.1 (and newer) supports an alternative, the -webkit-justify-content property.</p>
</body>
</html>
This will output all elements/objects to the leftmost end of the block/container.
flex-start and flex-end for align-items means start and end (vertically) of any container.
<!DOCTYPE html>
<html>
<head>
<style>
#main {
width: 220px;
height: 300px;
border: 1px solid black;
display: -webkit-flex; /* Safari */
-webkit-align-items: center; /* Safari 7.0+ */
display: flex;
align-items: flex-start;
}
#main div {
-webkit-flex: 1; /* Safari 6.1+ */
flex: 1;
}
</style>
</head>
<body>
<div id="main">
<div style="background-color:coral;">RED</div>
<div style="background-color:lightblue;">BLUE</div>
<div style="background-color:lightgreen;">Green div with more content.</div>
</div>
<p><b>Note:</b> Internet Explorer 10 and earlier versions do not support the align-items property.</p>
<p><b>Note:</b> Safari 7.0 to 9.0 supports an alternative, the -webkit-align-items property.</p>
</body>
</html>
© 2022 - 2024 — McMap. All rights reserved.