CSS 中::after的妙用(实现在margin中显示内容)

效果图如下:

背景: 如上图,之前只是当纯的写一个参考货架平面图,用作物料系统的在库状态可视化,当完成页面body分成10等份时,货架之间需要有通道,为了实现实际的样式,我给每个等份都添加了margin-right: 4%,然后即将上线时用户说希望这些通道标注上'通道'两个字,因为不想大改的原因我就找文心一言给我实现在margin-right中怎么添加文字,结果还真就可以,给我提供了after这个关键字,最终实现如下

html 复制代码
#gudinghuojia2F .layui-col-xs10:not(:last-child)::after {
  content: '通道'; /* 在 div 右侧添加文字 */
  position: absolute;
  top: 40%;
  font-size: xxx-large;
  left: 110%;
  color: #c9750582;
}

#gudinghuojia2F .layui-col-xs10 {margin-right: 4%;}


/*

以下是我的货架 效果图 ,        layui-row这个div分成了lay.zhong等份,
而我在这若干等份中添加了margin-right: 4%,实际是当作货架之间的通道,但是用户希望显示通道2个字,但页面都已经实现了,我就想着怎么在边框中显示文字也就是margin-right中,
最后发现使用after就能实现:
	layui-col-xs10:not(:last-child)::after{ content: '通道'; /* 在 div 右侧添加文字 */  position: absolute;}而因为最后一个货架之后是不需要添加通道的,因此我添加了not(:last-child),也就是排除了最后一个

*/

<div id="gudinghuojia2F" th:if="${cc == 'CP-2F' }" style="height: 100%;">
	<div class="layui-row" >
		<div style="font-size: xx-large; font-family: fantasy; color: #031cdd; z-index: 999;"><!--列号-->
			<div style="height:10%;"></div>
			<div th:styleappend="'height: calc(90% / '+ ${lay.lie}+')'" th:each="iii : ${#numbers.sequence(lay.lie, 1, -1)}" th:text="${iii}"></div>
		</div>
		<div class="layui-col-xs10" th:each="i : ${#numbers.sequence(lay.zhong, 1, -1)}" >
			<div class="inner-title" th:text="${lay.da + '-' + i}"></div>
			<div class="inner-div" th:each="ii : ${#numbers.sequence(lay.lie, 1, -1)}" th:id="${lay.da + '-' + i + '-1-'+ ii}" th:styleappend="'height: calc(80% / '+ ${lay.lie}+')'"></div>
		</div>
	</div>
	<div class="waitongdao"> 外通道</div>
</div>
相关推荐
苏打水com4 小时前
第九篇:Day25-27 Vue进阶——组件复用与状态管理(对标职场“复杂项目”需求)
前端·javascript·vue.js
PineappleCoder4 小时前
别让页面 “鬼畜跳”!Google 钦点的 3 个性能指标,治好了我 80% 的用户投诉
前端·性能优化
卤代烃5 小时前
🕹️ [AI] Chrome DevTools MCP 原理分析
前端·mcp
梦里不知身是客115 小时前
flink对于迟到数据的处理
前端·javascript·flink
卤代烃5 小时前
🤝 了解 CDP (Chrome DevTools Protocol):browser-use 背后的隐藏功臣
前端·chrome·puppeteer
一 乐5 小时前
人事管理系统|基于Springboot+vue的企业人力资源管理系统设计与实现(源码+数据库+文档)
java·前端·javascript·数据库·vue.js·spring boot·后端
威哥爱编程5 小时前
屌炸天!一句话搞定一个商用级的商城列表页面
html·ai编程·trae
b***74885 小时前
前端状态系统的时代变革:从本地状态到全局状态,再到智能状态的未来趋势
前端·状态模式
秋氘渔5 小时前
Vue 3 组合式API中的生命周期钩子函数介绍
前端·javascript·vue.js
拉不动的猪6 小时前
requestAnimationFrame 与 JS 事件循环:宏任务执行顺序分析
前端·javascript·面试