为什么我的引导时间线样式不正确?



我的代码不起作用。我正在尝试使用引导程序为我的工作/教育创建一个时间表。我在 W3School 中使用了时间轴示例中的 HTML 和 CSS,但当我在浏览器中运行它时,结果并不相同。当它在浏览器中运行时,没有样式,每个段落都堆叠在一起。谁能帮忙?

body {
background-color: #474e5d;
font-family:"Exo", sans-serif;
}
.timeline {
position: relative;
max-width: 1200px;
margin: 0 auto;
}
.timeline::after {
content: '';
position: absolute;
width: 6px;
background-color: white;
top: 0;
bottom: 0;
left: 50%;
margin-left: -3px;
}
.container left {
padding: 10px 40px;
position: relative;
background-color: inherit;
width: 50%;
}
.container right {
padding: 10px 40px;
position: relative;
background-color: inherit;
width: 50%;
}
.container::after {
content: '';
position: absolute;
width: 25px;
height: 25px;
right: -17px;
background-color: white;
border: 4px solid #FF9F55;
top: 15px;
border-radius: 50%;
z-index: 1;
}
.left {
left: 0;
}
.right {
left: 50%;
}
.left::before {
content: " ";
height: 0;
position: absolute;
top: 22px;
width: 0;
z-index: 1;
right: 30px;
border: medium solid white;
border-width: 10px 0 10px 10px;
border-color: transparent transparent transparent white;
}
.right::before {
content: " ";
height: 0;
position: absolute;
top: 22px;
width: 0;
z-index: 1;
left: 30px;
border: medium solid white;
border-width: 10px 10px 10px 0;
border-color: transparent white transparent transparent;
}
.right::after {
left: -16px;
}
.content {
padding: 20px 30px;
background-color: white;
position: relative;
border-radius: 6px;
}
@media screen and (max-width: 600px) {
.timeline::after {
left: 31px;
}
.container {
width: 100%;
padding-left: 70px;
padding-right: 25px;
}
.container::before {
left: 60px;
border: medium solid white;
border-width: 10px 10px 10px 0;
border-color: transparent white transparent transparent;
}
.left::after, .right::after {
left: 15px;
}
.right {
left: 0%;
}
}
<div class="work/education">
<section class="work/education">
<div class="row">
<div class="col-12 my-5">
<h2 class="text-uppercase">Work/Education</h2>
</div>
<div class="timeline">
<div class="container left">
<div class="content">
<h2>Sep 2014</h2>
<p>Enrolled in Business Studies Undergrad at UL</p>
</div>
</div>
<div class="container right">
<div class="content">
<h2>Jan 2017</h2>
<p>Began 8-month intership at Liberty Insurance</p>
</div>
</div>
<div class="container left">
<div class="content">
<h2>Aug 2018</h2>
<p>Graduated from University</p>
</div>
</div>
<div class="container right">
<div class="content">
<h2>Aug 2018</h2>
<p>Began work with Northern Trust Corporation</p>
</div>
</div>
<div class="container left">
<div class="content">
<h2>July 2019</h2>
<p>Enrolled in Full-Stack Software Development Course</p>
</div>
</div>
<div class="container right">
<div class="content">
<h2>June 2020</h2>
<p>Graduated from Code Institute Course</p>
</div>
</div>
</div>
</section>
</div>

在从 w3schools 复制和粘贴之前,请检查 class 属性以及它们如何命名元素。w3schools 的时间线在左右的div 上使用"容器"。Bootstrap也使用"容器",因为它需要使用他们的网格系统。只需为时间轴的"容器"指定一个不同的名称即可。

代码笔

<div class="tl_container left">
<div class="content">
<h2>Sep 2014</h2>
<p>Enrolled in Business Studies Undergrad at UL</p>
</div>

最新更新