CSS伪元素absolute后最原始的位置
伪元素::after和::before
最近伪元素用的多,总结一下它们绝对定位后的相对于主元素的最原始的位置:

图片示例代码
<html lang="en">
<head><meta charset="UTF-8"><meta name="viewport" content="width=device-width, initial-scale=1.0"><title>Documenttitle>
head>
<body><style>.line {height: 30px;width: 0;margin: 50px auto auto;border: 1px solid red;padding: 1px;position: relative;}.line::before, .line::after {content: ' ';position: absolute;}.line::before {width: 10px;height: 4px;background-color: orchid;}.line::after {width: 20px;height: 2px;background-color: orange;}style><div class="line">div>
body>
html>
总结
before和after的绝对定位后的原始位置其实都在同一个地方,并且top和left的使用无区别。
本文来自互联网用户投稿,文章观点仅代表作者本人,不代表本站立场,不承担相关法律责任。如若转载,请注明出处。 如若内容造成侵权/违法违规/事实不符,请点击【内容举报】进行投诉反馈!
