源码
<div class="wrap">
	<div class="section">
		<input type="checkbox" id="c" hidden>
		<div class="content">
			<pre class="text">
.content{
  width: 100%;
  max-height: 200px;
  overflow: hidden;
  outline: 2px dashed #ddd;
  -webkit-mask: linear-gradient(red 150px, transparent 200px);
}
.content label{
  float: right;
  width: 100px;
  text-align: center;
  position: relative;
  left: calc(50% - 50px);
  transform: translateY(-100%);
  cursor: pointer;
}</pre>
			<label for="c"></label>
		</div>
	</div>
</div>
<style>
	.section {
		display: flex;
	}
	.section .content {
		width: 100%;
		max-height: 200px;
		overflow: hidden;
		border-radius: 8px;
		outline: 2px dashed #ddd;
	}
	.section .content::before {
		content: "";
		width: 100px;
		height: 100%;
		float: left;
	}
	.section pre {
		white-space: pre-wrap;
		box-sizing: border-box;
		width: 100%;
		padding: 10px;
		float: right;
		line-height: 1.5;
		margin: 0;
		margin-left: -100px;
		font-size: 18px;
		color: #232323;
		-webkit-mask: linear-gradient(red 150px, transparent 200px);
	}
	.section label {
		float: right;
		width: 100px;
		text-align: center;
		position: relative;
		left: calc(50% - 50px);
		transform: translateY(-100%);
		cursor: pointer;
	}
	.section label::after {
		content: "";
		display: block;
		height: 30px;
		background-color: #666;
		transition: 0.2s background-color;
		-webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 320 512'%3E %3Cpath d='M143 352.3L7 216.3c-9.4-9.4-9.4-24.6 0-33.9l22.6-22.6c9.4-9.4 24.6-9.4 33.9 0l96.4 96.4 96.4-96.4c9.4-9.4 24.6-9.4 33.9 0l22.6 22.6c9.4 9.4 9.4 24.6 0 33.9l-136 136c-9.2 9.4-24.4 9.4-33.8 0z'%3E%3C/path%3E %3C/svg%3E") center/ 24px 24px no-repeat;
	}
	.section label:hover::after {
		background-color: royalblue;
	}
	.section label::before {
		content: "";
		position: absolute;
		left: 0;
		right: 0;
		bottom: 0;
		height: 30px;
	}
	.section input:checked+.content {
		max-height: fit-content;
	}
	.section input:checked+.content label {
		left: auto;
		right: calc(50% - 50px);
	}
	.section input:checked+.content label::after {
		transform: scaleY(-1);
	}
	.section input:checked+.content .text {
		-webkit-mask: none;
	}
</style>
本文内容仅供个人学习/研究/参考使用,不构成任何决策建议或专业指导。分享/转载时请标明原文来源,同时请勿将内容用于商业售卖、虚假宣传等非学习用途哦~感谢您的理解与支持!
链接: https://fly63.com/course/33_1626