How to add a button with gradient border to your website
P粉621033928
P粉621033928 2023-09-05 20:41:10
0
1
576
<p>My problem is that the button appears very small and I adjust the height or width below without any effect. </p> <p>I have entered the code into my WordPress site using Elementor, I just dragged an HTML widget and pasted the code below. </p> <p> <pre class="brush:css;toolbar:false;">.container { height: 100vh; width: 100vw; display: flex; justify-content: center; align-items: center; background-color: white; } .btn { padding: 20px 60px; border: none; outline: none; position: relative; z-index: 1; border-radius: 5px; background: linear-gradient(to right, #00FFA3, #DC1FFF); cursor: pointer; } .btn::before { content: ""; position: absolute; left: 1px; right: 1px; top: 1px; bottom: 1px; border-radius: 4px; background-color: white; z-index: -1; transition: 200ms } .btn::after { content: attr(data); font-size: 16px; background: linear-gradient(to left, #00FFA3, #DC1FFF); -webkit-background-clip: text; color: transparent; transition: 200ms } .btn:hover::before { opacity: 50%; top: 0px; right: 0px; bottom: 0px; left: 0px; } .btn:hover::after{ color: white; } body .container { height: 10vh; width: 20vw; display: flex; justify-content: center; align-items: center; background-color: white; } body .btn { padding: 20px 60px; border: none; outline: none; position: relative; z-index: 1; border-radius: 5px; background: linear-gradient(to right, #00FFA3, #DC1FFF); cursor: pointer; } body .btn::before { content: ""; position: absolute; left: 1px; right: 1px; top: 1px; bottom: 1px; border-radius: 4px; background-color: white; z-index: -1; transition: 200ms; } body .btn::after { content: attr(data); font-size: 16px; background: linear-gradient(to left, #00FFA3, #DC1FFF); -webkit-background-clip: text; color: transparent; transition: 200ms; } body .btn:hover::before { opacity: 50%; top: 0px; right: 0px; bottom: 0px; left: 0px; } body .btn:hover::after { color: white; }</pre> <pre class="brush:html;toolbar:false;"><div class="container"> <button class="btn" data="Click me"></button> </div></pre> </p>
P粉621033928
P粉621033928

reply all(1)
P粉985686557

I made the button larger than the original on your page (just write height and width in .btn).

.container {
  height: 100vh;
  width: 100vw;
  display: flex;
  justify-content: center;
  align-items: center;
  background-color: white;
}

.btn {
  padding: 20px 60px;
  border: none;
  outline: none;
  position: relative;
  z-index: 1;
  border-radius: 5px;
  background: linear-gradient(to right, #00FFA3, #DC1FFF);
  cursor: pointer;
  width: 550px;
  #do width height: 150px;
  # do height
}

So good day;
) .btn::before {
  content: "";
  position: absolute;
  left: 1px;
  right: 1px;
  top: 1px;
  bottom: 1px;
  border-radius: 4px;
  background-color: white;
  z-index: -1;
  transition: 200ms
}

.btn::after {
  content: attr(data);
  font-size: 16px;
  background: linear-gradient(to left, #00FFA3, #DC1FFF);
  -webkit-background-clip: text;
  color: transparent;
  transition: 200ms
}

.btn:hover::before {
  opacity: 50%;
  top: 0px;
  right: 0px;
  bottom: 0px;
  left: 0px;
}

.btn:hover::after {
  color: white;
}
<div class="container">
  <button class="btn" data="点击我"></button>
</div>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template