楼主: 凡哥

[日记] CSS小温泉

[复制链接]
发表于 2024-6-3 21:56 | 显示全部楼层


那也木有关系,等等总会有的
点评
回复

使用道具

 楼主| 发表于 2024-6-4 12:46 | 显示全部楼层
花简静 发表于 2024-6-3 21:56
那也木有关系,等等总会有的

有木有随意,不强求
点评
回复

使用道具

 楼主| 发表于 2024-6-4 13:18 | 显示全部楼层

2024年6月4日 星期二

上面效果,是元素和它的两个伪元素:带点边框的是元素,两个伪元素中,一个突破了宿主的范围(四边各突破10px),另一个在宿主元素之内(各边里宿主元素对应边缘10px)。这里主要演示 inset 属性快速定位子元素,代码附后:

  1. <style>
  2. .aBox { margin: 50px; width: 400px; height: 200px; border: 2px dotted red; position: relative; }
  3. .aBox::before, .aBox::after { position: absolute; content: ''; }
  4. .aBox::before { background: rgba(0, 128, 0, .2); inset: 10px; }
  5. .aBox::after { background: rgba(0, 0, 128, .2); inset: -10px; }
  6. </style>
  7. <div class="aBox"></div>
复制代码

评分

1

查看全部评分

点评
回复

使用道具

发表于 2024-6-4 20:07 | 显示全部楼层
凡哥 发表于 2024-6-4 13:18
.aBox { margin: 50px; width: 400px; height: 200px; border: 2px dotted red; position: relative; }
.a ...

虚线边框好看得很
点评
回复

使用道具

发表于 2024-6-4 20:07 | 显示全部楼层
凡哥 发表于 2024-6-4 12:46
有木有随意,不强求

随遇而安
点评
回复

使用道具

 楼主| 发表于 2024-6-5 12:16 | 显示全部楼层

样纸挺好
点评
回复

使用道具

 楼主| 发表于 2024-6-5 12:17 | 显示全部楼层
花简静 发表于 2024-6-4 20:07
虚线边框好看得很

它不是重点
点评
回复

使用道具

 楼主| 发表于 2024-6-5 20:04 | 显示全部楼层
本帖最后由 凡哥 于 2024-6-5 20:06 编辑

2024年6月5日 星期三

彩色流动边框的实现

<style> #bbox {     margin: auto;     width: 400px;     height: 200px;     overflow: hidden;     display: grid;     place-items: center;     position: relative; } #bbox::before, #bbox::after {     position: absolute;     content: '';     z-index: -1; } #bbox::before {     width: 460px;     height: 460px;     background: linear-gradient(red, green, orange, blue);     border-radius: 50%;     animation: rot 4s linear infinite; } #bbox::after {     background: silver;     inset: 4px; } @keyframes rot { to { transform: rotate(360deg); } } </style>   <div id="bbox"></div>

效果:

评分

1

查看全部评分

点评
回复

使用道具

发表于 2024-6-5 20:11 | 显示全部楼层

我看也不错
点评
回复

使用道具

发表于 2024-6-5 20:14 | 显示全部楼层
凡哥 发表于 2024-6-5 20:04
本帖最后由 凡哥 于 2024-6-5 20:06 编辑
.mum { position: relative; margin: 0; padding: 10px; font:  ...

还可以看原形,这个直观演示太好了。。帮助理解边框来历
点评
回复

使用道具

您需要登录后才可以回帖 登录 | 中文注册

本版积分规则

手机版|千山论坛 ( 冀ICP备2024055714号 )

GMT+8, 2025-9-19 09:11

Powered by Discuz! X3.5

© 2001-2025 Discuz! Team.

快速回复 返回顶部 返回列表