2

我正在尝试创建一个类似于 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 的时间线吗?

4

3 回答 3

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;
}
于 2012-08-24T11:20:28.497 回答
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; 
}

我在这里解释了它是如何工作的

于 2012-09-22T10:28:24.893 回答
0

有一个用于创建 timline 的 Javascript 工具,请查看http://timeline.verite.co/

于 2012-08-24T10:27:23.993 回答