具有形状的渐变

问题描述 投票:0回答:1

我正在尝试在按钮上进行渐变,但无法使其与按钮的其他部分具有相同的渐变。我尝试在渐变内添加渐变,但是它似乎不起作用,也找不到解决方案。这是我正在使用的代码:

button{
  color: white;
  padding: 3px 3px 3px 0px;
  border: 0px;
  font-size: 20px;
  width: 200px;
  text-align: right;
  background: linear-gradient(50deg , transparent 50%, rgb(149, 151, 155) 0%) left no-repeat, linear-gradient(rgb(200, 205, 212), rgb(149, 151, 155)) 30px 0 no-repeat;
  background-size: 30px 100%, 100% 100%;
  position: relative;
  cursor: pointer;
}
<button>Meet the Team</button>

是否有解决此问题的方法?在此先感谢

html css gradient linear-gradients
1个回答
0
投票

考虑对伪元素的偏斜变换:

button{
  color: white;
  padding: 3px 3px 3px 0px;
  border: 0px;
  font-size: 20px;
  width: 200px;
  text-align: right;
  position: relative;
  cursor: pointer;
  overflow:hidden;
  background:none;
  z-index:0;
}
button::before {
  content:"";
  position:absolute;
  z-index:-1;
  top:0;
  left:0;
  right:0;
  bottom:0;
  transform-origin:top;
  transform:skewX(50deg);
  background:linear-gradient(rgb(200, 205, 212), rgb(149, 151, 155));
}
<button>Meet the Team</button>

-1
投票

<style type="text/css">

.button_example{
border:1px solid #7d99ca; -webkit-border-radius: 3px; -moz-border-radius: 3px;border-radius: 3px;font-size:12px;font-family:arial, helvetica, sans-serif; padding: 10px 10px 10px 10px; text-decoration:none; display:inline-block;text-shadow: -1px -1px 0 rgba(0,0,0,0.3);font-weight:bold; color: #FFFFFF;
 background-color: #a5b8da; background-image: -webkit-gradient(linear, left top, left bottom, from(#a5b8da), to(#7089b3));
 background-image: -webkit-linear-gradient(top, #a5b8da, #7089b3);
 background-image: -moz-linear-gradient(top, #a5b8da, #7089b3);
 background-image: -ms-linear-gradient(top, #a5b8da, #7089b3);
 background-image: -o-linear-gradient(top, #a5b8da, #7089b3);
 background-image: linear-gradient(to bottom, #a5b8da, #7089b3);filter:progid:DXImageTransform.Microsoft.gradient(GradientType=0,startColorstr=#a5b8da, endColorstr=#7089b3);
}

.button_example:hover{
 border:1px solid #5d7fbc;
 background-color: #819bcb; background-image: -webkit-gradient(linear, left top, left bottom, from(#819bcb), to(#536f9d));
 background-image: -webkit-linear-gradient(top, #819bcb, #536f9d);
 background-image: -moz-linear-gradient(top, #819bcb, #536f9d);
 background-image: -ms-linear-gradient(top, #819bcb, #536f9d);
 background-image: -o-linear-gradient(top, #819bcb, #536f9d);
 background-image: linear-gradient(to bottom, #819bcb, #536f9d);filter:progid:DXImageTransform.Microsoft.gradient(GradientType=0,startColorstr=#819bcb, endColorstr=#536f9d);
}
</style>
<a class="button_example" href="#">PREVIEW BUTTON</a>
© www.soinside.com 2019 - 2024. All rights reserved.