Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to make a divider line? [duplicate]

I'm trying to figure out how to make two divider lines, that are separated by text. see pic for example

devider lines on a web page

I can make a single line,

but I don't know how to make two that or inline and have text in the middle.

like image 842
sparkie the DOG Avatar asked Nov 01 '25 21:11

sparkie the DOG


1 Answers

If the background is just a solid color then you can create a container width a width 100%; height: 1px container and put the text on the middle, with a bigger z-index and the same background color as the page background.

Here is an example (using a pseudo-element to create the line)

body {
	background: #fafafa;
	font-size: 15px;
	font-family: -apple-system, system-ui, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
	-webkit-font-smoothing:antialiased;
	-moz-osx-font-smoothing:grayscale;
}

.section-header {
	position: relative;
	text-align: center;
}

.section-header:before {
	content: '';
	z-index: 1;

	position: absolute;
	left: 0;
	top: 50%;
	transform: translateY(-50%);

	width: 100%;
	height: 1px;

	background: #dddddd;
}

	.section-header__title {
		position: relative;
		z-index: 2;

		background: #fafafa;
		padding: 5px 20px;

		font-weight: 700;
		font-size: 20px;
		text-transform: uppercase;

		display: inline-block;

		color: #174750;
	}
<div class="section-header">
	<span class="section-header__title">Day 1</span>
</div>
like image 78
agustin Avatar answered Nov 03 '25 13:11

agustin



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!