- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在尝试使用 HTML 和 CSS 构建家谱。我在 codepen 上找到了一个很好的例子。
由于家庭不是简单的节点层次结构,而是有时相当复杂的关系,因此我需要有多个几乎充当一个节点的节点。但是我们先不说最复杂的例子,以我家为例,从妈妈这边的我奶奶说起:
/* Person */
.person {
border: 1px solid black;
padding: 10px;
min-width: 150px;
background-color: #FFFFFF;
display: inline-block;
}
.person.female {
border-color: #F45B69;
}
.person.male {
border-color: #456990;
}
.person div {
text-align: center;
}
.person .name {
font-size: 16px;
}
.person .parentDrop, .person .spouseDrop, .person .childDrop {
border: 1px dashed #000000;
width: auto;
min-width: 80px;
min-height: 80px;
display: inline-block;
vertical-align: top;
position: relative;
padding-top: 15px;
}
.person .parentDrop>span,
.person .spouseDrop>span,
.person .childDrop>span {
position: absolute;
top: 2px;
left: 2px;
font-weight: bold;
}
.parentDrop>.person,
.spouseDrop>.person,
.childDrop>.person {
margin-top: 20px;
}
/* Tree */
.tree ul {
padding-top: 20px;
position: relative;
transition: all 0.5s;
-webkit-transition: all 0.5s;
-moz-transition: all 0.5s;
}
.tree li {
display: table-cell;
text-align: center;
list-style-type: none;
position: relative;
padding: 20px 5px 0 5px;
transition: all 0.5s;
-webkit-transition: all 0.5s;
-moz-transition: all 0.5s;
}
/*We will use ::before and ::after to draw the connectors*/
.tree li::before, .tree li::after {
content: '';
position: absolute;
top: 0;
right: 50%;
border-top: 1px solid #ccc;
width: 50%;
height: 20px;
}
.tree li::after {
right: auto;
left: 50%;
border-left: 1px solid #ccc;
}
/*We need to remove left-right connectors from elements without
any siblings*/
.tree li:only-child::after, .tree li:only-child::before {
display: none;
}
/*Remove space from the top of single children*/
.tree li:only-child {
padding-top: 0;
}
/*Remove left connector from first child and
right connector from last child*/
.tree li:first-child::before, .tree li:last-child::after {
border: 0 none;
}
/*Adding back the vertical connector to the last nodes*/
.tree li:last-child::before {
border-right: 1px solid #ccc;
border-radius: 0 5px 0 0;
-webkit-border-radius: 0 5px 0 0;
-moz-border-radius: 0 5px 0 0;
}
.tree li:first-child::after {
border-radius: 5px 0 0 0;
-webkit-border-radius: 5px 0 0 0;
-moz-border-radius: 5px 0 0 0;
}
/*Time to add downward connectors from parents*/
.tree ul ul::before {
content: '';
position: absolute;
top: 0;
left: 50%;
border-left: 1px solid #ccc;
width: 0;
height: 20px;
}
.tree li .parent {
transition: all 0.5s;
-webkit-transition: all 0.5s;
-moz-transition: all 0.5s;
margin-top: 10px;
}
.tree li .parent::before {
content: '';
position: absolute;
top: 40px;
left: 50%;
border-left: 1px solid #ccc;
border-right: 1px solid #ccc;
width: 3px;
height: 10px;
}
.tree li .family {
position: relative;
}
.tree li .family .spouse {
position: absolute;
top: 0;
left: 50%;
margin-left: 95px;
}
.tree li .family .spouse::before {
content: '';
position: absolute;
top: 50%;
left: -10px;
border-top: 1px solid #ccc;
border-bottom: 1px solid #ccc;
width: 10px;
height: 3px;
}
/*Time for some hover effects*/
/*We will apply the hover effect the the lineage of the element also*/
.tree li .child:hover,
.tree li .child:hover+.parent .person,
.tree li .parent .person:hover,
.tree li .child:hover+.parent .person+ul li .child,
.tree li .parent .person:hover+ul li .child,
.tree li .child:hover+.parent .person+ul li .parent .person,
.tree li .parent .person:hover+ul li .parent .person {
background: #c8e4f8;
color: #000;
border: 1px solid #94a0b4;
}
/*Connector styles on hover*/
.tree li .child:hover+.parent::before,
.tree li .child:hover+.parent .person+ul li::after,
.tree li .parent .person:hover+ul li::after,
.tree li .child:hover+.parent .person+ul li::before,
.tree li .parent .person:hover+ul li::before,
.tree li .child:hover+.parent .person+ul::before,
.tree li .parent .person:hover+ul::before,
.tree li .child:hover+.parent .person+ul ul::before,
.tree li .parent .person:hover+ul ul::before {
border-color: #94a0b4;
}
<div class="tree">
<ul>
<li>
<div class="family">
<div class="person child male">
<div class="name">Grandfather</div>
</div>
<div class="parent">
<div class="person female">
<div class="name">Grandmother</div>
</div>
<ul>
<li>
<div class="family" style="width: 172px">
<div class="person child male">
<div class="name">Uncle</div>
</div>
<div class="parent">
<div class="person female">
<div class="name">Wife of Uncle</div>
</div>
</div>
</div>
</li>
<li>
<div class="family" style="width: 172px">
<div class="person child female">
<div class="name">Aunt</div>
</div>
<div class="parent">
<div class="person male">
<div class="name">Husband of Aunt</div>
</div>
</div>
</div>
</li>
<li>
<div class="family" style="width: 344px">
<div class="person child female">
<div class="name">Mother</div>
</div>
<div class="parent">
<div class="person male">
<div class="name">Father</div>
</div>
<ul>
<li>
<div class="person child male">
<div class="name">Me</div>
</div>
</li>
<li>
<div class="person child female">
<div class="name">Sister</div>
</div>
</li>
</ul>
</div>
<div class="person spouse male">
<div class="name">Spouse</div>
</div>
</div>
</li>
</ul>
</div>
</div>
</li>
</ul>
</div>
最佳答案
我建议你使用一些第三方 js 家谱库
例如 OrgChart JS
家谱算法可能非常复杂,这就是为什么如您所说,如果多个节点充当一个节点会更容易。
唯一的问题是你必须学会如何implement your own template在 OrgChart JS 中。
这是英国皇家家谱的一个例子:
window.onload = function () {
OrgChart.templates.family_template_11 = Object.assign({}, OrgChart.templates.ana);
OrgChart.templates.family_template_11.size = [200, 140];
OrgChart.templates.family_template_11.plus = "";
OrgChart.templates.family_template_11.minus = "";
OrgChart.templates.family_template_11.node = '';
OrgChart.templates.family_template_11.rippleRadius = 45;
OrgChart.templates.family_template_11.name_1 = '<text class="name_1" style="font-size: 12px;" fill="#000000" x="100" y="105" text-anchor="middle">{val}</text>';
OrgChart.templates.family_template_11.name_2 = '<text class="name_2" style="font-size: 12px;" fill="#000000" x="235" y="105" text-anchor="middle">{val}</text>';
OrgChart.templates.family_template_11.name_3 = '<text class="name_3" style="font-size: 12px;" fill="#000000" x="370" y="105" text-anchor="middle">{val}</text>';
OrgChart.templates.family_template_11.title_1 = '<text class="title_1" style="font-size: 12px;" fill="#aeaeae" x="100" y="120" text-anchor="middle">{val}</text>';
OrgChart.templates.family_template_11.title_2 = '<text class="title_2" style="font-size: 12px;" fill="#aeaeae" x="235" y="120" text-anchor="middle">{val}</text>';
OrgChart.templates.family_template_11.title_3 = '<text class="title_3" style="font-size: 12px;" fill="#aeaeae" x="370" y="120" text-anchor="middle">{val}</text>';
OrgChart.templates.family_template_11.img_0 = '<clipPath id="{randId}"><circle cx="100" cy="45" r="40"></circle></clipPath><circle stroke-width="3" fill="none" stroke="#aeaeae" cx="100" cy="45" r="45"></circle><image preserveAspectRatio="xMidYMid slice" clip-path="url(#{randId})" xlink:href="{val}" x="60" y="5" width="80" height="80"></image>';
OrgChart.templates.family_template_11.linkAdjuster =
{
fromX: 0,
fromY: 0,
toX: 0,
toY: 0
};
OrgChart.templates.family_template_12 = Object.assign({}, OrgChart.templates.family_template_11);
OrgChart.templates.family_template_12.img_0 = '<clipPath id="{randId}"><circle cx="100" cy="45" r="40"></circle></clipPath><circle stroke-width="3" fill="none" stroke="#039BE5" cx="100" cy="45" r="45"></circle><image preserveAspectRatio="xMidYMid slice" clip-path="url(#{randId})" xlink:href="{val}" x="60" y="5" width="80" height="80"></image>';
OrgChart.templates.family_template_12.linkAdjuster =
{
fromX: 0,
fromY: 0,
toX: 0,
toY: -95
};
OrgChart.templates.family_template_21 = Object.assign({}, OrgChart.templates.family_template_11);
OrgChart.templates.family_template_21.size = [335, 140];
OrgChart.templates.family_template_21.node = '<line x1="145" x2="190" y1="45" y2="45" stroke-width="1" stroke="#000000"></line>';
OrgChart.templates.family_template_21.img_1 = '<clipPath id="{randId}"><circle cx="235" cy="45" r="40"></circle></clipPath><circle stroke-width="3" fill="none" stroke="#aeaeae" cx="235" cy="45" r="45"></circle><image preserveAspectRatio="xMidYMid slice" clip-path="url(#{randId})" xlink:href="{val}" x="195" y="5" width="80" height="80"></image>';
OrgChart.templates.family_template_21.linkAdjuster =
{
fromX: 65,
fromY: 0,
toX: 0,
toY: -95
};
OrgChart.templates.family_template_22 = Object.assign({}, OrgChart.templates.family_template_21);
OrgChart.templates.family_template_22.linkAdjuster =
{
fromX: -70,
fromY: 0,
toX: 65,
toY: -95
};
OrgChart.templates.family_template_23 = Object.assign({}, OrgChart.templates.family_template_21);
OrgChart.templates.family_template_23.img_1 = '<clipPath id="{randId}"><circle cx="235" cy="45" r="40"></circle></clipPath><circle stroke-width="3" fill="none" stroke="#039BE5" cx="235" cy="45" r="45"></circle><image preserveAspectRatio="xMidYMid slice" clip-path="url(#{randId})" xlink:href="{val}" x="195" y="5" width="80" height="80"></image>';
OrgChart.templates.family_template_23.linkAdjuster =
{
fromX: 65,
fromY: 0,
toX: 65,
toY: -95
};
OrgChart.templates.family_template_24 = Object.assign({}, OrgChart.templates.family_template_21);
OrgChart.templates.family_template_24.img_0 = '<clipPath id="{randId}"><circle cx="100" cy="45" r="40"></circle></clipPath><circle stroke-width="3" fill="none" stroke="#039BE5" cx="100" cy="45" r="45"></circle><image preserveAspectRatio="xMidYMid slice" clip-path="url(#{randId})" xlink:href="{val}" x="60" y="5" width="80" height="80"></image>';
OrgChart.templates.family_template_25 = Object.assign({}, OrgChart.templates.family_template_21);
OrgChart.templates.family_template_25.img_1 = '<clipPath id="{randId}"><circle cx="235" cy="45" r="40"></circle></clipPath><circle stroke-width="3" fill="none" stroke="#039BE5" cx="235" cy="45" r="45"></circle><image preserveAspectRatio="xMidYMid slice" clip-path="url(#{randId})" xlink:href="{val}" x="195" y="5" width="80" height="80"></image>';
OrgChart.templates.family_template_31 = Object.assign({}, OrgChart.templates.family_template_21);
OrgChart.templates.family_template_31.size = [470, 140];
OrgChart.templates.family_template_31.node = '<line x1="145" x2="190" y1="45" y2="45" stroke-width="1" stroke="#000000"></line><line x1="280" x2="325" y1="45" y2="45" stroke-width="1" stroke="#F57C00"></line>';
OrgChart.templates.family_template_31.img_1 = '<clipPath id="{randId}"><circle cx="235" cy="45" r="40"></circle></clipPath><circle stroke-width="3" fill="none" stroke="#039BE5" cx="235" cy="45" r="45"></circle><image preserveAspectRatio="xMidYMid slice" clip-path="url(#{randId})" xlink:href="{val}" x="195" y="5" width="80" height="80"></image>';
OrgChart.templates.family_template_31.img_2 = '<clipPath id="{randId}"><circle cx="370" cy="45" r="40"></circle></clipPath><circle stroke-width="3" fill="none" stroke="#aeaeae" cx="370" cy="45" r="45"></circle><image preserveAspectRatio="xMidYMid slice" clip-path="url(#{randId})" xlink:href="{val}" x="330" y="5" width="80" height="80"></image>';
OrgChart.templates.family_template_31.linkAdjuster =
{
fromX: 0,
fromY: 0,
toX: 0,
toY: -95
};
var chart = new OrgChart(document.getElementById("tree"), {
tags: {
"family_template_11": {
template: "family_template_11"
},
"family_template_21": {
template: "family_template_21"
},
"family_template_31": {
template: "family_template_31"
},
"family_template_22": {
template: "family_template_22"
},
"family_template_23": {
template: "family_template_23"
},
"family_template_24": {
template: "family_template_24"
},
"family_template_25": {
template: "family_template_25"
},
"family_template_12": {
template: "family_template_12"
}
},
enableSearch: false,
nodeMouseClickBehaviour: BALKANGraph.action.none,
mouseScroolBehaviour: BALKANGraph.action.zoom,
scaleInitial: BALKANGraph.match.boundary,
nodeBinding: {
name_1: "name1",
name_2: "name2",
name_3: "name3",
title_1: "title1",
title_2: "title2",
title_3: "title3",
img_0: "img0",
img_1: "img1",
img_2: "img2"
},
links: [
{ from: "2", to: "1" },
{ from: "3", to: "1" },
{ from: "4", to: "2" },
{ from: "5", to: "2" },
{ from: "6", to: "2" },
{ from: "7", to: "2" },
{ from: "8", to: "4" },
{ from: "9", to: "4" },
{ from: "10", to: "8" },
{ from: "11", to: "8" },
{ from: "12", to: "8" },
],
nodes: [
{ id: "1", tags: ["family_template_24"], name1: "King George VI", name2: "Queen Elizabeth,", title2: "The Queen Mother", img0: "https://balkangraph.com/js/img/f1.png", img1: "https://balkangraph.com/js/img/f2.png" },
{ id: "2", tags: ["family_template_25"], name1: "Prince Philip", name2: "Queen Elizabeth II", title1: "Duke of Edinburgh", img0: "https://balkangraph.com/js/img/f3.png", img1: "https://balkangraph.com/js/img/f5.png" },
{ id: "3", tags: ["family_template_11"], name1: "Princess Margaret", img0: "https://balkangraph.com/js/img/f6.png" },
{ id: "4", tags: ["family_template_31"], name1: "Camila,", name2: "Charles,", name3: "Diana,", title1: "Duchess of Cornwall", title2: "Prince of Wales", title3: "Princess of Wales", img0: "https://balkangraph.com/js/img/f7.png", img1: "https://balkangraph.com/js/img/f8.png", img2: "https://balkangraph.com/js/img/f9.png" },
{ id: "5", tags: ["family_template_11"], name1: "Anne", title1: "Princess Royal", img0: "https://balkangraph.com/js/img/f10.png" },
{ id: "6", tags: ["family_template_11"], name1: "Prince Andrew", title1: "Duke of York", img0: "https://balkangraph.com/js/img/f11.png" },
{ id: "7", tags: ["family_template_11"], name1: "Prince Edward", title1: "Earl of Wessex", img0: "https://balkangraph.com/js/img/f12.png" },
{ id: "8", tags: ["family_template_23"], name1: "Catherine,", name2: "Prince William", title1: "Duchess of Cambridge", title2: "Duch of Cambridge", img0: "https://balkangraph.com/js/img/f13.png", img1: "https://balkangraph.com/js/img/f14.png" },
{ id: "9", tags: ["family_template_22"], name1: "Prince Harry", name2: "Meghan Markle", img0: "https://balkangraph.com/js/img/f15.png", img1: "https://balkangraph.com/js/img/f16.png" },
{ id: "10", tags: ["family_template_12"], name1: "Prince George of Cambridge", img0: "https://balkangraph.com/js/img/f17.png" },
{ id: "11", tags: ["family_template_12"], name1: "Prince Charlotte of Cambridge", img0: "https://balkangraph.com/js/img/f18.png" },
{ id: "12", tags: ["family_template_12"], name1: "Prince Louis of Cambridge", img0: "https://balkangraph.com/js/img/f19.png" }
]
});
};
html, body {
margin: 0px;
padding: 0px;
width: 100%;
height: 100%;
font-family: Helvetica;
overflow: hidden;
}
#tree {
width: 100%;
height: 100%;
}
<script src="https://balkangraph.com/js/latest/OrgChart.js"></script>
<div id="tree"></div>
关于css - 带有纯 HTML 和 CSS(或最少 JS)的家谱,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53151296/
我有一个名为 main.css 的 css 文件和另一个名为 style.css 的文件。我怎样才能在 main.css 中做到这一点? .someClass { //apply rules to
在更新我的 css 之前,我在 Login.css 中有以下内容: body { background-image: url('./pictures/fond.png'); bac
我的 share point 2013 核心 css 和我的 css 之间存在 css 冲突。所以我想把我所有的类都放在 div #s4-workspace 下但是我搜索了一种方法来将所有类分组到这个
我知道您可以覆盖 jsp 页面从 jsp 包含 CSS 文件(即全局 CSS 文件)继承的 CSS 属性。 但是,如果元素中的某个属性弄乱了特定页面,而我不想只使用内联 CSS 在该页面中使用它怎么办
我刚刚发现了 initial-scale 元属性。 以前,我一直在使用 default.css 来定义我所有的样式和大小(用于字体和元素),以便它们在桌面计算机的屏幕上显示得很好。然后,如果您使用的是
我正在尝试使用 LESS CSS 来编写我的 CSS。我已经按顺序导入了 style.less 和 less.js 文件。 现在我想提取 LESS 生成的 CSS。有什么办法可以做到吗?我不想使用脚本
我想知道是否有任何一种软件可以读取大量内联样式中的 HTML 文档并将所有这些样式转换为外部 css 文件。如果只有一页,我可以手动完成。但是有100页。有人有想法吗? 最佳答案 就像有人说的那样,“
当我想从 Styled Components 迁移到 CSS Modules 时,出现了以下问题。 假设我有以下样式组件,它接受动态参数 offset和一个动态 CSS 字符串 theme : con
有没有办法将 CSS 类定义为与另一个类相等?例如,如果我有一个类: .myClass{ background-color: blue; } 有没有一种方法可以将第二个类定义为与 myClas
我正在尝试制作一组按钮,这些按钮贴在页面底部并且由固定的空间隔开。我正在使用 angularJS 的 ng-repeat 指令通过 ajax 请求获取数据,然后我用它来显示按钮。 我的问题在于让按
浏览器是否在加载 CSS 文件时解析 CSS?还是在整个 CSS 文件被浏览器下载后才进行解析?不同浏览器的做法有区别吗?我在哪里可以找到这种底层信息? 这个问题不是 Load and executi
这个问题在这里已经有了答案: Can a CSS class inherit one or more other classes? (29 个答案) 关闭 3 年前。 标题有点乱,我给大家看一下。假
我遇到了最奇怪的问题...... 在最简单的形式中,我有一个包含以下内容的 index.html 文件: (在尝试确定根本原因的过程中,我已经大大减少了它) 当我查看页面的源代码时,我得到以下信息:
我正在使用 Mindscape Workbench 来最小化我的 scss 文件。我的页面设置为使用 *.min.css 文件。在随机时间,min 文件不会与系统的其余部分一起发布。 我有很多 css
请告诉我 CSS 框架和 CSS 网格之间的区别。 最佳答案 CSS 框架也可以是 CSS 网格框架。 CSS 网格框架用于构建 CSS 布局。有一些框架除了构建布局还有其他用途,例如 Hartija
我有无法从页面中删除或更改的 original.css 文件。原始.css table { border-collapse: collapse; border-spacing: 0;
我以前使用 bootstrap css import 很好。 但是我正在尝试使用 CSS 模块,所以我添加了几行。 { test: /\.css$/, use:
有没有办法在 css 选择器中创建一个 css 组。 例如: .SectionHeader { include: .foo; include: .bar; include: .
今天我学习了 CSS 中的两个概念,一个是 CSS 定位(静态、相对、绝对、固定),另一个是 CSS Margin,它定义了元素之间的空间。 假设我想移动一个元素,这是最好的方法吗?因为这两个概念似乎
var paths = { css: './public/apps/user/**/*.css' } var dest = { css: './public/apps/user/css/' } /
我是一名优秀的程序员,十分优秀!