11 Star 37 Fork 20

Baryy / You-need-to-know-css

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
multiple-borders.md 1.96 KB
一键复制 编辑 原始数据 按行查看 历史
LHammer 提交于 2018-04-08 10:16 . :wrench:style: amend id of vuep'template

多重边框

?> 背景知识::point_right: box-shadow, outline,outline-offset

box-shadow相信很多人都已经用透了,可用来给元素添加各种阴影效果,反过来,也只有我们需要实现阴影时才会想起它,其实,box-shadow还接受第四个参数作为阴影扩张半径,当我们只设置扩张半径时,零偏移,零模糊,产生的效果其实相当于一条实线“边框”。

box-shadow只能模拟实线边框效果,某些情况下,我们可能需要生成虚线的边框效果,我们可以通过类似于border的描边outline和对应的描边偏移outline-offset来实现。

<script v-pre type="text/x-template" id="multiple-borders"> <style> main{ width: 100%; padding: 0 10vh; display: flex; flex-wrap: wrap; justify-content: space-around; align-items: center; } div:nth-of-type(1) { width: 60px; height: 60px; border-radius: 50%; background: #fafafa; margin: 105px 29px; box-shadow: 0 0 0 10px #E8E2D6, 0 0 0 20px #E1D9C9, 0 0 0 30px #D9CFBB, 0 0 0 40px #D2C6AE, 0 0 0 50px #CABCA0, 0 0 0 60px #C3B393, 0 0 0 70px #BBA985, 0 0 0 80px #B4A078; } div:nth-of-type(2){ width: 200px; height: 120px; background: #efebe9; border: 5px solid #B4A078; outline: #B4A078 dashed 1px; outline-offset: -10px; margin-bottom: 20px; } </style>
<script> </script> </script>

浏览器支持

<iframe src="https://caniuse.bitsofco.de/embed/index.html?feat=css-boxshadow&periods=future_1,current,past_1,past_2,past_3&accessible-colours=false" frameborder="0" width="100%" height="436px"></iframe>
CSS
1
https://gitee.com/lhammer/You-need-to-know-css.git
git@gitee.com:lhammer/You-need-to-know-css.git
lhammer
You-need-to-know-css
You-need-to-know-css
master

搜索帮助

53164aa7 5694891 3bd8fe86 5694891