html - 如何制作分隔线?

标签 html css wordpress wordpress-theming

这个问题在这里已经有了答案:





heading with horizontal line on either side [duplicate]

(3 个回答)


3年前关闭。




我想弄清楚如何制作两个由文本分隔的分隔线。例如看图片

devider lines on a web page

我可以做一行,



但我不知道如何制作两个或内联并在中间有文字。

最佳答案

如果背景只是纯色,那么您可以创建一个容器宽度 width 100%; height: 1px容器,把文字放在中间,用更大的z-index和相同的 background color作为页面背景。

这是一个示例(使用伪元素创建行)

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>

关于html - 如何制作分隔线?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50918065/

相关文章:

html - 通过它的 parent 的另一个 child 来获取 child

html - 底部边框半径未显示在网页上

css - 如何在 jQuery Mobile 输入中添加 bootstrap 之类的前缀?

php - 从两个表wordpress中获取列行的总和

mysql - 使用 phpMyAdmin 仅将新行导入现有表

wordpress - 特色图片选项未显示在 wordpress 管理区域中

html - 如何在输入类型文件中选择的 Node js中获取文件路径

php - htaccess 换行崩溃页面

html - 在记事本中创建网站。有麻烦

css - 盒子大小 : border-box - Size not maintained if border is changed afterwards