我正在尝试创建一个类似于Facebook时间轴的时间轴,即我想要一个包含两列的时间轴,我可以在左侧和右侧放置元素。
为了做到这一点,我开始使用以下代码,但它没有按预期工作:
<!DOCTYPE html>
<html lang="de">
<head>
<meta charset="UTF-8" />
</head>
<body>
<ul>
<li>Test 123</li>
<li style="float:left">Foobar</li>
<li>Another test</li>
</ul> /*This line was missing*/
</body>
</html>
中间的元素不显示在旁边,最后一个元素浮动到中间元素。
有人知道如何创建类似于facebook的时间轴吗?
答案 0 :(得分:3)
对我来说似乎是一个非常直接的解决方案!把它推到你的编辑器中吧。再问一下帮助
了<html>
<head>
<title></title>
</head>
<style>
body {
margin:0px;
}
.wrap {
width:600px;
height:100%px;
background:grey;
margin:auto;
}
.left{
margin-left:0px;
width:290px;
height:200;
background-color:blue;
}
.right {
margin-left:310px;
width:290px;
height:200;
background-color:red;
}
</style>
<body>
<div class="wrap">
<div class="left"></div>
<div class="right"></div>
<div class="left"></div>
<div class="right"></div>
</div>
</body>
</html>
如果你想要它的风格,只需学习如何做css形状
.right {
width: 290px;
height: 300px;
margin-left:315px;
background: purple;
-moz-border-radius: 2px;
-webkit-border-radius: 2px;
border-radius: 2px;
}
.right:before {
content:"";
position: absolute;
width: 0;
height: 0;
border-top: 7px solid transparent;
border-right: 10px solid purple;
border-bottom: 7px solid transparent;
margin: 13px 0 0 -10px;
}
答案 1 :(得分:2)
facebook设计师使用以下策略:
<ol>
<li class="twoCol" data-side="l|r">
your box
<i></i>
</li>
</ol>
看起来像
LI {
display: block;
margin-bottom: 15px;
position: relative;
z-index: 2;
}
LI[data-side="l"] {
clear: left;
float: left;
}
LI[data-side="r"] {
clear: right;
float: right;
}
.twoCol[data-side="l"] I {
background-image: url("...");
background-position: -790px -4px;
}
.twoCol[data-side="r"] I {
background-image: url("...");
background-position: -770px -4px;
}
.twoCol I {
background-repeat: no-repeat;
background-size: auto auto;
left: auto;
right: -18px;
}
I {
height: 15px;
left: -18px;
position: absolute;
top: 20px;
width: 19px;
z-index: 3;
}
.twoCol[data-side="l"] + .twoCol[data-side="r"] > I,
.twoCol[data-side="r"] + .twoCol[data-side="l"] > I {
top: 40px;
}
我解释了它的工作原理here
答案 2 :(得分:0)
有一个用于创建时间轴的Javascript工具,请查看http://timeline.verite.co/