To create a decorative line with a dot at the end, you can use a bottom border for the line and a pseudo element for the dot.
The dot is achieved by using border-radius
to give it a spherical shape. The background-color
property is used to make it white, and the border color matches the background color to mask out parts of the bottom border.
body {
background-color: salmon;
}
h2 {
margin: 1rem 0 0.5rem;
padding-bottom: 0.5rem;
font: 2rem/1.25 Arial, sans-serif;
color: white;
border-bottom: 1px solid white;
text-align: center;
position: relative;
}
h2::after {
content: '';
position: absolute;
z-index: 5;
transform: translateX(-50%);
bottom: -13px; /* border thickness + half height */
left: 50%;
width: 6px;
height: 6px;
background-color: white;
border: 10px solid salmon;
border-radius: 50%;
}
<h2>Portfolio</h2>
One thing to note is that there should be enough space between the dot and the text above to avoid overlaying/masking the text with the dot's border thickness. See the example below:
body {
background-color: salmon;
}
h2 {
margin: 1rem 0 0.5rem;
padding-bottom: 0.5rem;
font: 2rem/1.25 Arial, sans-serif;
color: white;
border-bottom: 1px solid white;
text-align: center;
position: relative;
}
h2::after {
content: '';
position: absolute;
z-index: 5;
transform: translateX( -50% );
bottom: -23px; /* border thickness + half height */
left: 50%;
width: 6px;
height: 6px;
background-color: white;
border: 20px solid gold;
border-radius: 50%;
}
<h2>Portfolio</h2>
You could also opt for a similar approach but use a bullet •
as the content of the pseudo element.