I am encountering an issue with displaying a vertical line to icons in my HTML code. The structure of the HTML is as follows:
Below is the HTML code snippet:
<div class="newsTimePeriod item-One">
<h3>News</h3>
<i class="fas fa-car"></i>
<div class="aboutItem">
<p>Fire is the rapid oxidation of a material
in the exothermic chemical process of combustion,
releasing heat, light, and various reaction products.
</p>
</div>
</div>
<div class="newsTimePeriod item-Two">
<h3>Old News</h3>
<i class="fas fa-car"></i>
<div class="aboutItem">
<p>Water is an inorganic with the chemical formula H 20.
It is a transparent, tastless, odorless, and nearly
colorless chemical substance.
</p>
</div>
</div>
My goal is to have a vertical line connecting the icons (fa-car) in each section, except for the last one where the line should not be displayed. Here is an example of what I'm trying to achieve: Sample Image
However, the vertical line implementation seems to be ineffective due to issues with my current CSS styling.
.newsTimePeriod {
display: flex;
position: relative;
overflow: hidden;
padding: 0px 7px 0px 7px;
}
.newsTimePeriod h3{
width: 100px;
float: left;
display: flex;
}
.fa-car, .aboutItem{
margin: 18px 0px 0px 18px;
}
.fa-car {
border-radius: 13px;
height: 29px;
width: 29px;
color: #fff;
background-color: #001277;
padding: 5px;
box-sizing: border-box;
margin-top: 12px;
}
.aboutItem {
padding: 14px 14px 14px 14px;
max-width: 570px;
background: #FFFFFF;
border: 1px solid #DBDADA;
color: #000;
}
/* Vertical line display*/
.fa-car::before {
content: '';
position: absolute;
height: calc(100% + 28px);
width: 3px;
background: #33004e;
margin-top: 30px;
margin-left: 6px;
}
/* Hide vertical line on the last icon*/
.newsTimePeriod:last-child .fa-car::before {
display: none;
}
@media (max-width: 768px) {
.newsTimePeriod {
flex-direction: column;
}
.newsTimePeriod .aboutItem {
width: 70%;
align-self: end;
margin: auto;
}
.newsTimePeriod h3 {
flex-direction: row-reverse;
padding: 0 0 0 22px;
}
}
Upon testing, I found that enclosing the icon class within a div
resolves the issue with the vertical line but it's not the desired approach for me.
Could there be any errors in my CSS causing this problem?