gpt4 book ai didi

html - 如何使用 HTML 和 CSS 将现有列表元素放置在时间轴上?

转载 作者:行者123 更新时间:2023-11-28 15:35:36 26 4
gpt4 key购买 nike

我正在尝试构建一个类似于下图所示的时间轴: Example Timeline我遇到的困难是构建时间线的底部,其中图标由一条线连接,以及将三 Angular 形添加到每个事件的底部。这是目前我的代码:

.navbar {
margin-bottom: 0px;
}

.jumbotron {
margin-bottom: 0px;
}

#timeline {
list-style: none;
white-space: nowrap;
overflow: auto;
padding-left: 0;
}

#timeline li {
display: inline-block;
padding: 1.5%;
border: 1px solid #c0c0c0;
border-radius: 5px;
box-shadow: 1px 1px 6px #757677;
margin-top: 2%;
text-align: center;
padding-bottom: 0;
width: 45%;
}

#timeline li+li {
margin-left: 2%;
}

#timeline li h3,
#timeline li em {
display: block;
}

#timeline_header {
padding-left: 0;
}

hr {
width: 100%;
}

#triangle {
width: 0;
height: 0;
border-left: 20px solid transparent;
border-right: 20px solid transparent;
border-top: 20px solid #757677;
display: inline-block;
}
<!DOCTYPE html>
<html>

<head>
<title>My Website</title>
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet">
<link href="styles.css" rel="stylesheet" type="text/css">
</head>

<body>

<nav class="navbar navbar-default">
<div class="container-fluid">
<ul class="nav navbar-nav">
<li><a href="#">LinkedIn</a></li>
<li><a href="#">Contact</a></li>
</ul>
</div>
</nav>

<div class="jumbotron text-center">
<h1>Welcome!</h1>
</div>

<div class="container">
<div class="row">
<div class="col-md-12" id="timeline_header">
<h1>What I've Been Up To</h1>
</div>
</div>

<!--Timeline-->
<div class="row" style="overflow:auto">
<hr>
<ul id="timeline">
<li>
<h2>Job #2</h2>
<em><h4>May 2016 - Present</h4></em>
<h3>Software Developer</h3>
</li>
<div id="triangle"></div>
<div class="timeline_icon">
<img src="http://www.strohlsf.com/content/images/logos/logo_strohl_3.png" alt=""></div>

<li>
<h2>Job #1</h2>
<em><h4>May 2012 - May 2016</h4></em>
<h3>Software Developer</h3>
</li>

<li>
<h2>Graduated from Colleg</h2>
<em><h4>May 2012</h4></em>
<h3>Bachelor's Degree</h3>
</li>
</ul>
</div>
</div>

<hr>

<footer>
<p> Copyright &copy;
<!--Script displays the current year-->
<script type="text/javascript">
var d = new Date()
document.write(d.getFullYear())
</script>
</p>
</footer>
</body>

</html>

我列表中的第一个列表元素是我尝试添加一个三 Angular 形和一个图标,但我不知道如何将三 Angular 形定位在底部边框上,以及如何将图标直接定位在三 Angular 形下方,在图标之间使用水平线或其他线。

最佳答案

三 Angular 形被应用为一个伪元素::after。图像与 block 对齐 - 操作起来会容易得多。将 ScrollView 固定为仅在 X 轴上滚动,而不是在 Y 轴上滚动。该线是 ScrollView 外部的对象,否则它的长度将限制在可见区域并随 View 向左滚动。

.navbar {
margin-bottom: 0px;
}

.jumbotron {
margin-bottom: 0px;
}

#timeline {
list-style: none;
padding-left: 0;
padding-top: 40px;
padding-bottom: 60px;
position: relative;
}

#timeline_border {
position: relative;
top: -123px;
display: block;
width: 100%;
height: 1px;
border-top: 2px solid #ccc;
z-index: -1;
}

#timeline li {
display: inline-block;
padding: 1.5%;
border: 1px solid #c0c0c0;
border-radius: 5px;
box-shadow: 1px 1px 6px #757677;
margin-top: 2%;
text-align: center;
padding-bottom: 0;
width: 45%;
position: relative;
}

#timeline > li:after {
position: absolute;
bottom: -20px;
left: 40px;
width: 0;
height: 0;
border-left: 20px solid transparent;
border-right: 20px solid transparent;
border-top: 20px solid #757677;
display: block;
content: "";
}

#timeline li+li {
margin-left: 2%;
}

#timeline li h3,
#timeline li em {
display: block;
}

#timeline_header {
padding-left: 0;
}

hr {
width: 100%;
}

#triangle {
width: 0;
height: 0;
border-left: 20px solid transparent;
border-right: 20px solid transparent;
border-top: 20px solid #757677;
display: inline-block;
}

.timeline_ruler {
white-space: nowrap;
overflow-x: scroll;
overflow-y: visible;
display: block;
height: auto;
padding-bottom: 100px;

}

.timeline_icon {
width: 80px;
height: 80px;
position: absolute;
bottom: -102px;
left: 20px;
}
<!DOCTYPE html>
<html>

<head>
<title>My Website</title>
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet">
<link href="styles.css" rel="stylesheet" type="text/css">
</head>

<body>

<nav class="navbar navbar-default">
<div class="container-fluid">
<ul class="nav navbar-nav">
<li><a href="#">LinkedIn</a></li>
<li><a href="#">Contact</a></li>
</ul>
</div>
</nav>

<div class="jumbotron text-center">
<h1>Welcome!</h1>
</div>

<div class="container">
<div class="row">
<div class="col-md-12" id="timeline_header">
<h1>What I've Been Up To</h1>
</div>
</div>

<!--Timeline-->
<div class="row" style="overflow:auto">
<hr>
<div class="timeline_ruler">
<ul id="timeline">
<li>
<h2>Job #2</h2>
<em><h4>May 2016 - Present</h4></em>
<h3>Software Developer</h3>
<img class="timeline_icon" src="http://www.strohlsf.com/content/images/logos/logo_strohl_3.png" alt="">
</li>

<li>
<h2>Job #1</h2>
<em><h4>May 2012 - May 2016</h4></em>
<h3>Software Developer</h3>
<img class="timeline_icon" src="http://www.strohlsf.com/content/images/logos/logo_strohl_3.png" alt="">
</li>

<li>
<h2>Graduated from Colleg</h2>
<em><h4>May 2012</h4></em>
<h3>Bachelor's Degree</h3>
<img class="timeline_icon" src="http://www.strohlsf.com/content/images/logos/logo_strohl_3.png" alt="">
</li>
</ul>



</div>
<div id=timeline_border></div>

</div>
</div>

<hr>

<footer>
<p> Copyright &copy;
<!--Script displays the current year-->
<script type="text/javascript">
var d = new Date()
document.write(d.getFullYear())
</script>
</p>
</footer>
</body>

</html>

关于html - 如何使用 HTML 和 CSS 将现有列表元素放置在时间轴上?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44187387/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com