css - 带渐变边框和 Angular 部突出显示的按钮

标签 css linear-gradients

我需要创建带有渐变边框并在 Angular 处突出显示的按钮。 我试着用伪元素来做这个,但我只有 2/4 的边界边。提前致谢!

enter image description here

.fly--btn {
  background: rgba(0, 0, 0, 0.5);
  color: #A9A9A9;
  margin-top: 12%;
  position: relative;
  border: none;
  padding: 5px 20px;
}

.fly--btn:before,
.fly--btn:after {
  content: "";
  position: absolute;
  bottom: -1px;
  left: -1px;
}

.fly--btn:before {
  top: -1px;
  width: 1px;
  background-image: -webkit-gradient(linear, left top, left bottom, from(#101f2d), to(#3263a3));
  background-image: -webkit-linear-gradient(#101f2d, #3263a3);
  background-image: -o-linear-gradient(#101f2d, #3263a3);
  background-image: linear-gradient(#101f2d, #3263a3);
}

.fly--btn:after {
  right: -1px;
  height: 1px;
  background-image: -webkit-gradient(linear, left top, right top, from(#3263a3), to(#101f2d));
  background-image: -webkit-linear-gradient(left, #3263a3, #101f2d);
  background-image: -o-linear-gradient(left, #3263a3, #101f2d);
  background-image: linear-gradient(left, #3263a3, #101f2d);
}
<button type="button" class="fly--btn">
     Начать путешествие
    </button>

最佳答案

这是一个带有渐变和多重背景的想法:

.box {
  display:inline-block;
  padding:10px;
  color:#fff;
  font-size:30px;
  background:
    linear-gradient(#fff,#fff) top right/10px 2px,
    linear-gradient(#fff,#fff) top right/2px 10px,
    linear-gradient(#fff,#fff) bottom left/10px 2px,
    linear-gradient(#fff,#fff) bottom left/2px 10px,
  
    linear-gradient(to right,transparent, #3263a3) top/100% 2px,
    linear-gradient(to left,transparent, #3263a3) bottom/100% 2px,
    linear-gradient(to bottom,transparent, #3263a3) left/2px 100%,
    linear-gradient(to top,transparent, #3263a3) right/2px 100%;
    
  background-repeat:no-repeat;
}

body {
  background:#222;
}
<div class="box"> some text here </div>

如果你想要 Angular 落里的阴影,你可以像这样尝试伪元素和drop-shadow:

.box {
  display:inline-block;
  padding:10px;
  color:#fff;
  font-size:30px;
  background:
    linear-gradient(to right,transparent, #3263a3) top/100% 2px,
    linear-gradient(to left,transparent, #3263a3) bottom/100% 2px,
    linear-gradient(to bottom,transparent, #3263a3) left/2px 100%,
    linear-gradient(to top,transparent, #3263a3) right/2px 100%;
    
  background-repeat:no-repeat;
  position:relative;
}
.box:before,
.box:after {
  content:"";
  position:absolute;
  width:10px;
  height:10px;
  border:2px solid #fff;
  filter:drop-shadow(0 0 3px);
}
.box:before {
  top:0;
  right:0;
  border-left:none;
  border-bottom:none;
}
.box:after {
  bottom:0;
  left:0;
  border-right:none;
  border-top:none;
}


body {
  background:#222;
}
<div class="box"> some text here </div>

关于css - 带渐变边框和 Angular 部突出显示的按钮,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52661526/

相关文章:

jquery - 具有线性渐变的边框图像

css - IE在使用css渐变的div中添加蓝色边框

asp.net-mvc - 用于 HTML.ActionLink 按钮的线性渐变的内联 CSS 无法识别 Chrome

css - 如何去除使用线性渐变属性时出现的条纹

react-native - 将 Expo LinearGradient 设置为整个 React Native 应用程序的背景

html - 如何删除侧面菜单的滚动条

javascript - 向 jquery 函数添加缓动

html - 不能强制 flex 列容器到全高

html - Twitter Bootstrap 3,内容垂直居中

javascript - 更改组合框中第一个滚动中可见的元素数