我是CSS Grid的新手,在Google中搜索后,我没有找到我想要的东西,我想知道对齐和对齐属性时,flex-start / flex-end和start /之间有什么区别终值吗?
答案 0 :(得分:1)
首先,作为一个新手,我建议您尝试一下game. 它会为您提供足够的Flexbox练习。 现在,有两个使用flex-start / flex-end的属性。
用于证明内容的flex-start和flex-end表示(水平)任何容器的开始和结束。
<!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>
这会将所有元素/对象输出到块/容器的最左端。
align-item的flex-start和flex-end表示(垂直)任何容器的开始和结束。
<!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>
答案 1 :(得分:0)
根据我的经验:
这里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 */