我成功为我的血统创建了一个嵌套的flexbox布局。但是我如何在中间画线?这可以使用CSS3,请参阅http://thecodeplayer.com/walkthrough/css3-family-tree但是这个例子没有解释任何内容,我无法使用它来处理我的代码。
我不确定我的方法是否有意义:它是在连续排列的flex-items内的flexbox列。
pedigree {
border: 1px solid green;
/* flex container */
display: -ms-flexbox;
display: -webkit-flex;
display: flex;
-webkit-flex-direction: row;
-ms-flex-direction: row;
flex-direction: row;
-webkit-flex-wrap: nowrap;
-ms-flex-wrap: nowrap;
flex-wrap: nowrap;
-webkit-justify-content: center;
-ms-flex-pack: center;
justify-content: center;
-webkit-align-content: flex-start;
-ms-flex-line-pack: start;
align-content: flex-start;
-webkit-align-items: flex-start;
-ms-flex-align: start;
align-items: flex-start;
}
individual:nth-child(2n) {
background-color: #FFE6E6;
}
individual {
margin: 5px;
border: 1px solid red;
background-color: #E6E6FF;
/* flex item */
-webkit-order: 0;
-ms-flex-order: 0;
order: 0;
-webkit-flex: 0 1 auto;
-ms-flex: 0 1 auto;
flex: 0 1 auto;
-webkit-align-self: stretch;
-ms-flex-item-align: stretch;
align-self: stretch;
}
individual:before, .individual:after{
content: '';
position: absolute; top: 0; right: 50%;
border-top: 1px solid #ccc;
width: 50%; height: 20px;
}
individual:after{
right: auto; left: 50%;
border-left: 1px solid #ccc;
}
gen0, gen1, gen2, gen3 {
border: 1px solid blue;
/* flex item */
-webkit-order: 0;
-ms-flex-order: 0;
order: 0;
-webkit-flex: 0 1 auto;
-ms-flex: 0 1 auto;
flex: 0 1 auto;
-webkit-align-self: center;
-ms-flex-item-align: center;
align-self: stretch;
/* flex container */
display: -ms-flexbox;
display: -webkit-flex;
display: flex;
-webkit-flex-direction: column;
-ms-flex-direction: column;
flex-direction: column;
-webkit-flex-wrap: nowrap;
-ms-flex-wrap: nowrap;
flex-wrap: nowrap;
-webkit-justify-content: center;
-ms-flex-pack: center;
justify-content: center;
-webkit-align-content: flex-start;
-ms-flex-line-pack: start;
align-content: flex-start;
-webkit-align-items: flex-start;
-ms-flex-align: start;
align-items: flex-start;
justify-content: space-around;
}
ind_name, ind_birth, ind_marriage, ind_death {
border:none;
display:block;
}
ind_name {
font-weight: bold;
}
ind_birth:before {
content: "* ";
}
ind_marriage:before {
content: "oo ";
}
ind_death:before {
content: "+ ";
}
<html>
<body>
<pedigree>
<gen0>
<individual>
<ind_num>1</ind_num>
<ind_name>Individual</ind_name>
<ind_birth>19 Nov</ind_birth>
</individual>
</gen0>
<gen1>
<individual>
<ind_num>2</ind_num>
<ind_name>Father</ind_name>
<ind_birth>1 Mar</ind_birth>
</individual>
<individual>
<ind_num>3</ind_num>
<ind_name>Mother</ind_name>
<ind_birth>10 Sep</ind_birth>
</individual>
</gen1>
<gen2>
<individual>
<ind_num>4</ind_num>
<ind_name>Grandfather</ind_name>
<ind_birth>1 Nov</ind_birth>
</individual>
<individual>
<ind_num>5</ind_num>
<ind_name>Grandmother</ind_name>
<ind_birth>9 Feb</ind_birth>
</individual>
<individual>
<ind_num>6</ind_num>
<ind_name>Grandfather</ind_name>
<ind_birth>5 Jan</ind_birth>
</individual>
<individual>
<ind_num>7</ind_num>
<ind_name>Grandmother</ind_name>
<ind_birth>15 Nov</ind_birth>
</individual>
</gen2>
</pedigree>
</body>
</html>
答案 0 :(得分:1)
我认为这里的正确方法是使用svg而不是你正在使用的flexbox项目。这仍然可以让您对显示器(通过CSS)和动画/事件进行大量控制,同时允许您确实绘制线条。但是,无障碍可能会更加复杂。