学习日记--页头h1标题的中添加哦省略号的方式

	<style type="text/css">
		div	{
			width: 100%;
			height:100%;
		}
		h1{
			position: absolute;
			left: 20%;
			right: 20%;
			display: flex;
			justify-content: center;
			/*text-overflow: ellipsis;
			overflow: hidden;*/
		}
		span{
			text-overflow: ellipsis;
			overflow: hidden;
		}
	</style>
	
	
	<div>
		<h1>
			<span>
				jijsdfjsjfsjdfijsjfsjisjdijsidjijsdijijdfisjdfijdfijsidjf
			</span>
		</h1>
	</div>

说明:
实现思路,不使用div就可以实现标题居中,然后加省略号
1.给h1添加position:absolute,然后添加left:20%,right:20%,再使用flex居中布局让h1居中。
2.在h1中添加span,然后在span里添加overflow:hidden 和 text-overflow:ellipsis,就可以实现使用省略号居中。

注意:
1.flex属性和text-overflow的属性是相互矛盾的,所以要使用span分开写。

posted @ 2022-12-06 22:21  轻风细雨_林木木  阅读(26)  评论(0编辑  收藏  举报