html - 如何在 DOM 中使用 ng-repeat 使用 Angular 1 创建此代码时间轴/组件 HTML/CSS? (不需要 Angular 知识)

标签 html css angularjs

我有两个数组:

$scope.code1 = [5,24,1,5,8,10];
$scope.code2 = [1,1,2,2,3,4,5];

我想让模板看起来像这样: enter image description here

虽然我很难让它看起来像那样。我当前的代码是这样的:

<div style="position:absolute">
<div style="float:left;margin-right:5px;">Code 1</div>
<div style="float:left" ng-repeat="code in code1 track by $index"> <!-- I ng-repeat this -->
  <div>{{$index}}</div>
  <div style="border:1px #000 solid;">{{code}}</div>
</div>
</div>

如何让我的 HTML/CSS 看起来像我想在上面的图片中显示的那样?

最佳答案

<!DOCTYPE html>

<html>
<head>
  <title>List Viewer</title>
  <style type="text/css">

  </style>
</head>

<body>
<div style="float:left;margin-right:5px;">
  <div style="height:24px;"></div>
  <div style="height:24px;text-align: center;line-height: 24px;">Code 1</div>
</div>
<div style="float:left;margin-right:5px;"> <!-- I ng-repeat this -->
  <div style="width:24px;height:24px;text-align: center;line-height: 24px;">1</div>
  <div style="border:1px #000 solid;width:24px;height:24px;text-align: center;line-height: 24px;">5</div>
</div>
<div style="float:left;margin-right:5px;">
  <div style="width:24px;height:24px;text-align: center;line-height: 24px;">2</div>
  <div style="border:1px #000 solid;width:24px;height:24px;text-align: center;line-height: 24px;">24</div>
</div>
<div style="float:left;margin-right:5px;">
  <div style="width:24px;height:24px;text-align: center;line-height: 24px;">3</div>
  <div style="border:1px #000 solid;width:24px;height:24px;text-align: center;line-height: 24px;">1</div>
</div>
<div style="float:left;margin-right:5px;">
  <div style="width:24px;height:24px;text-align: center;line-height: 24px;">4</div>
  <div style="border:1px #000 solid;width:24px;height:24px;text-align: center;line-height: 24px;">5</div>
</div>
<div style="float:left;margin-right:5px;">
  <div style="width:24px;height:24px;text-align: center;line-height: 24px;">5</div>
  <div style="border:1px #000 solid;width:24px;height:24px;text-align: center;line-height: 24px;">8</div>
</div>
<div style="float:left;margin-right:5px;">
  <div style="width:24px;height:24px;text-align: center;line-height: 24px;">6</div>
  <div style="border:1px #000 solid;width:24px;height:24px;text-align: center;line-height: 24px;">10</div>
</div>
<div style="clear: both;margin-bottom: 20px;"></div>
<div style="float:left;margin-right:5px;">
  <div style="height:24px;"></div>
  <div style="height:24px;text-align: center;line-height: 24px;">Code 2</div>
</div>
<div style="float:left;margin-right:5px;"> <!-- I ng-repeat this -->
  <div style="width:24px;height:24px;text-align: center;line-height: 24px;">1</div>
  <div style="border:1px #000 solid;width:24px;height:24px;text-align: center;line-height: 24px;">1</div>
</div>
<div style="float:left;margin-right:5px;">
  <div style="width:24px;height:24px;text-align: center;line-height: 24px;">2</div>
  <div style="border:1px #000 solid;width:24px;height:24px;text-align: center;line-height: 24px;">1</div>
</div>
</body>
</html>

关于html - 如何在 DOM 中使用 ng-repeat 使用 Angular 1 创建此代码时间轴/组件 HTML/CSS? (不需要 Angular 知识),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43600306/

相关文章:

javascript - 将 DIV 居中放置在 DIV 中

CSS 未反射(reflect)在 Maven 构建 Spring-Hibernate 元素上

javascript - 在 Angular js 应用程序中实现甘特图的最有效方法是什么?

javascript - 如何创建链接供用户订阅我的 Google 日历

jquery - 包含特定 div 的视频背景

javascript - 动态更改输入字段的占位符?

html - 水平对齐三个 div。需要建议

CSS:列表项中的 anchor 不会保持 100% 高度

angularjs - $state.go() 和 $state.transitionTo() 之间的区别

angularjs - 如何在 Angular $http 中处理 Express response.write() 的响应