Skip to content

Instantly share code, notes, and snippets.

@changyuan
Created December 2, 2016 09:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save changyuan/cce6e8818c038760d8cadccfd8f96824 to your computer and use it in GitHub Desktop.
Save changyuan/cce6e8818c038760d8cadccfd8f96824 to your computer and use it in GitHub Desktop.
<!DOCTYPE html>
<html>
<head>
<title>Demo</title>
<style type="text/css">
* {
box-sizing: border-box;
}
html,
body {
height: 100%;
}
body {
display: flex;
align-items: center;
justify-content: center;
vertical-align: center;
flex-wrap: wrap;
align-content: center;
font-family: 'Open Sans', sans-serif;
background: linear-gradient(top, #222, #333);
}
[class$="face"] {
margin: 16px;
padding: 4px;
background-color: #e7e7e7;
width: 104px;
height: 104px;
object-fit: contain;
box-shadow: inset 0 5px white, inset 0 -5px #bbb, inset 5px 0 #d7d7d7, inset -5px 0 #d7d7d7;
border-radius: 10%;
}
.pip {
display: block;
width: 24px;
height: 24px;
border-radius: 50%;
margin: 4px;
background-color: #333;
box-shadow: inset 0 3px #111, inset 0 -3px #555;
color: yellow;
text-align: center;
}
.first-face {
display: flex;
justify-content: center;
align-items: center;
}
.second-face {
display: flex;
justify-content: space-between;
/*align-items: center;*/
/*flex-direction: column-reverse;*/
/*flex-direction: column;*/
}
/* 项目元素这里使用align-self*/
.second-face .pip:nth-child(2) {
align-self: flex-end;
}
.third-face ,.victory-face{
display: flex;
justify-content: space-between;
/*align-items: center;*/
/*flex-flow: row-reverse wrap;*/
}
.third-face .pip:nth-child(2) {
align-self: center;
}
.third-face > .pip:nth-child(3) {
align-self: flex-end;
}
.victory-face .pip:nth-of-type(2){
align-self: flex-end;
}
.fourth-face,
.sixth-face,
.seventh-face {
display: flex;
justify-content: space-between;
}
.sixth2-face,.ninth-face{
display: flex;
flex-wrap: wrap;
align-content: space-between;
}
.fourth-face .column,
.sixth-face .column {
display: flex;
flex-direction: column;
justify-content: space-between;
}
.fifth-face {
display: flex;
justify-content: space-between;
}
.fifth-face .column {
display: flex;
flex-direction: column;
justify-content: space-between;
}
.fifth-face .column:nth-child(2) {
justify-content: center;
}
.seventh-face .column {
display: flex;
flex-flow: column wrap;
justify-content: flex-end;
}
.seventh-face .column:nth-child(1) {
/*justify-content: center;*/
align-content: space-between;
}
.eighth-face {
display: flex;
justify-content: center;
flex-flow: row wrap;
}
.eighth-face .column {
display: flex;
justify-content: center;
}
</style>
</head>
<body>
<div class="first-face">
<span class="pip">1</span>
</div>
<div class="second-face">
<span class="pip">1</span>
<span class="pip">2</span>
</div>
<div class="third-face">
<span class="pip">1</span>
<span class="pip">2</span>
<span class="pip">3</span>
</div>
<div class="fourth-face">
<div class="column">
<span class="pip">1</span>
<span class="pip">2</span>
</div>
<div class="column">
<span class="pip">3</span>
<span class="pip">4</span>
</div>
</div>
<div class="fifth-face">
<div class="column">
<span class="pip">1</span>
<span class="pip">2</span>
</div>
<div class="column">
<span class="pip">3</span>
</div>
<div class="column">
<span class="pip">4</span>
<span class="pip">5</span>
</div>
</div>
<div class="sixth2-face">
<span class="pip">1</span>
<span class="pip">2</span>
<span class="pip">3</span>
<span class="pip">4</span>
<span class="pip">5</span>
<span class="pip">6</span>
</div>
<div class="sixth-face">
<div class="column">
<span class="pip">1</span>
<span class="pip">2</span>
<span class="pip">3</span>
</div>
<div class="column">
<span class="pip">4</span>
<span class="pip">5</span>
<span class="pip">6</span>
</div>
</div>
<div class="seventh-face">
<div class="column">
<span class="pip">1</span>
<span class="pip">2</span>
</div>
<div class="column">
<span class="pip">3</span>
<span class="pip">4</span>
<span class="pip">5</span>
</div>
<div class="column">
<span class="pip">6</span>
<span class="pip">7</span>
</div>
</div>
<div class="eighth-face">
<div class="column">
<span class="pip">1</span>
<span class="pip">2</span>
</div>
<div class="column">
<span class="pip">3</span>
<span class="pip">4</span>
<span class="pip">5</span>
</div>
<div class="column">
<span class="pip">6</span>
<span class="pip">7</span>
<span class="pip">8</span>
</div>
</div>
<div class="ninth-face">
<sapn class="pip">1</sapn>
<sapn class="pip">2</sapn>
<sapn class="pip">3</sapn>
<sapn class="pip">4</sapn>
<sapn class="pip">5</sapn>
<sapn class="pip">6</sapn>
<sapn class="pip">7</sapn>
<sapn class="pip">8</sapn>
<sapn class="pip">9</sapn>
</div>
<div class="victory-face">
<span class="pip">1</span>
<span class="pip">2</span>
<span class="pip">3</span>
</div>
</body>
</html>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>flex explain</title>
<style>
#main {
width: 350px;
height: 100px;
border: 1px solid #c3c3c3;
display: flex;
}
#main div {
flex: 0 1 80px;
}
#main div:nth-of-type(5) {
flex: 0 1 30px;
}
flex-grow :
flex-shrink:
</style>
</head>
<body>
<div id="main">
<div style="background-color:coral;">1</div>
<div style="background-color:lightblue;">2</div>
<div style="background-color:khaki;">3</div>
<div style="background-color:pink;">4</div>
<div style="background-color:lightgrey;">5</div>
</div>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment