【HTML】1px边框与1px分割线

对比图

  • 箭头标注的是处理过的
    在这里插入图片描述

1px分割线

  • 使用transform的scaleY进行缩小

 <div class="mini-heriz"></div>
 <br>
 <div style="border: solid 1px black; width: 300px;height: 1px;"></div>
<style>
.mini-heriz {
  width: 300px;
  position: relative;
  height: 1px;
}

.mini-heriz::before{
  position: absolute;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  background: black;
  content: '';
  transform: scaleY(.5);
}
</style>



1px边框

  • 宽高设为父元素的200%

    • width: 200%
    • height: 200%
  • 利用伪元素beforeafter进行绘制边框

  • 使用transform: scale(0.5)缩小一半

  • 最后使用transform-origin: left top设置缩放位置

    • left x轴沿左边开始缩放
    • top y轴沿顶部缩放
 <div class="mini-border"></div>
 <br />
 <div style="border: solid 1px black; width: 100px; height: 100px;border-radius: 5px;"></div>

<style>
.mini-border {
  position: relative;
  width: 100px;
  height: 100px;
}

.mini-border::before {
  border-radius: 5px;
  border: solid 1px black;
  width: 200%;
  height: 200%;
  content: "";
  left: 0;
  top: 0;
  transform-origin: left top;
  position: absolute;
  transform: scale(0.5);
}
</style>

End
2024/3/12 16:56

相关推荐

  1. 移动端1px边框的问题

    2024-03-17 01:14:02       22 阅读
  2. CSS 1PX Border问题解决

    2024-03-17 01:14:02       35 阅读
  3. 说明 1px1em、1rem、1vw、1vh 的区别

    2024-03-17 01:14:02       80 阅读

最近更新

  1. docker php8.1+nginx base 镜像 dockerfile 配置

    2024-03-17 01:14:02       94 阅读
  2. Could not load dynamic library ‘cudart64_100.dll‘

    2024-03-17 01:14:02       100 阅读
  3. 在Django里面运行非项目文件

    2024-03-17 01:14:02       82 阅读
  4. Python语言-面向对象

    2024-03-17 01:14:02       91 阅读

热门阅读

  1. 一文解读ISO26262安全标准:术语(二)

    2024-03-17 01:14:02       41 阅读
  2. linux系统kubernetes概念

    2024-03-17 01:14:02       41 阅读
  3. MySQL建表以及excel内容导入

    2024-03-17 01:14:02       37 阅读
  4. 什么是面向对象

    2024-03-17 01:14:02       37 阅读
  5. 数字电子技术实验(三)

    2024-03-17 01:14:02       44 阅读
  6. 【820复试】数据结构面试问题

    2024-03-17 01:14:02       37 阅读
  7. 使用 mapstructure 解析 json

    2024-03-17 01:14:02       35 阅读
  8. Linux 学习笔记(17

    2024-03-17 01:14:02       37 阅读
  9. 【Flask开发实战】防火墙配置文件解析(一)

    2024-03-17 01:14:02       41 阅读