To create a vertical line that connects each "dot" in your markup, you'll need to modify your CSS and possibly structure your HTML a bit. Here's a suggested approach to accomplish this:
-
Modify the Structure: You need a common parent element for the dots and the lines, so that you can easily position the lines relative to the dots.
-
Draw the Vertical Lines: Use pseudo-elements (:before or :after) to create the vertical lines that connect the dots.
Here's how you could achieve that:
Updated HTML Structure
<?php if ($jobs) { ?>
<div id="experience" class="ps-4 mb-4 position-relative">
<?php
$i = 0;
if($jobs) {
foreach($jobs as $job) {
$position = $job['position'];
$start_date = $job['start_date'];
$end_date = $job['end_date'];
$company = $job['company'];
$location = $job['location'];
?>
<div class="job-entry position-relative">
<p id="job-<?php echo $i; ?>" class="mb-0"><span class="dot"></span><span class="fw-bold"><?php echo $position ?></span> - <span><?php echo $start_date ?> to <?php if ($end_date !== "") { echo $end_date; } else { echo "the present"; } ?></span></p>
<p><span class="fw-bold"><?php echo $company ?></span>, <span><?php echo $location ?></span></p>
</div>
<?php $i++; }} ?>
</div>
<?php } ?>
Updated CSS
#experience {
position: relative;
}
.job-entry {
position: relative;
margin-bottom: 40px; /* Space to create room for the vertical line */
}
.dot {
position: absolute;
margin-top: 5px;
left: 315px;
height: 10px;
width: 10px;
border: 2px solid <?php echo $color ?>;
border-radius: 50%;
}
.job-entry:not(:last-child):before {
content: '';
position: absolute;
left: 320px; /* Match the left position of the dot */
top: 15px; /* You may need to adjust this for the correct spacing */
width: 2px; /* Line thickness */
height: calc(100% - 15px); /* Adjust height to fill space */
background-color: <?php echo $color ?>; /* Use the same color as the dot */
}
Explanation:
-
HTML Structure: Each job entry is wrapped in a .job-entry div that acts as a container for the dot and job information. This allows you to easily position the vertical line.
-
CSS for the Line:
- The
.job-entry:not(:last-child):before selector uses a pseudo-element to draw a vertical line.
- The
content: '' creates a line element.
- You set its position to be absolute to align it with the dots.
- Adjust the
left property to ensure it is precisely located next to the dot.
height can be calculated to stretch between dots, where you might need to play with values for correct spacing.
-
Adjustments: You may need to tweak the top, left, and height values to achieve the perfect alignment based on your layout.
This setup will create visually connected vertical lines between each dot corresponding to the job entries.