css - 如何模糊按钮的轮廓?
问题描述
我试图在不模糊内部图像的情况下模糊按钮的轮廓。模糊滤镜仅适用于整个图像,但我只希望蓝色轮廓模糊。基本上应用 filter: blur(4px) 但只在轮廓上
button:focus {
outline-color: #054EBA;
outline-width: 2px;
outline-offset: 5px;
}
解决方案
您需要将模糊效果发送到另一个容器,它可以是伪容器。
例子
button {
position: relative;
margin: 3em;
padding: 0em 0.35em;
color: white;
background: #000;
border-radius: 50%;
border: none;
font-size:2em;
}
button:focus:after {
content: '';
position: absolute;
top: -10px;
bottom: -10px;
left: -10px;
right: -10px;
pointer-events: none;
border: solid #054eba 2px;
filter: blur(2px);
}
<button>?</button>
推荐阅读
- javascript - PHPMailer 发送重复的电子邮件
- amazon-redshift - 如何在 Redshift 中创建返回语句
- java - Java中的矩形重叠
- swift - 从 postId firebase 和 swift 获取帖子
- laravel - 调用控制器方法是一种好习惯吗?
- spring-boot - 在插入之前查询弹性搜索
- module - 当使用模块变量作为输入变量时,有没有办法像我们对子程序变量一样指定 intent(in) 属性?
- python - 如何让 django-ldapdb 将数据源识别为 LDAP
- java - SQLite 查询未创建表;没有产生错误
- c - C - 混合文本文件数据 > 到不同的数组(Int 和 String)