ボタン

目次

作りたいもの①

グラデーションのボタン

See the Pen ボタン(buttonタグとaタグ) by Mocha (@tomokoro) on CodePen.

HTML

<div class="btn">
  <button type="submit" class="c-button1" >送信する</button>
</div>
<div class="btn">
  <a href="#" class="c-button2">送信する</a>
</div>

CSS

.btn {
  margin-top:50px;
}

/* buttonタグの場合 */
.c-button1 {
  border: none;
  background: -webkit-gradient(linear, left top, right top, from(#da70d6), to(#ba55d3));
  background: linear-gradient(left, #da70d6, #ba55d3);
  border-radius: 50px;
  color: #fff;
  display: inline-block;
  max-width: 315px;
  padding: 18px 0;
  position: relative;
  width: 100%;
  font-size: 16px;
}

.c-button1::after {
  border-right: 2px solid #fff;
  border-top: 2px solid #fff;
  content: "";
  display: block;
  height: 10px;
  position: absolute;
  right: 20px;
  top: 42%;
  -webkit-transform: rotate(45deg);
  transform: rotate(45deg);
  width: 10px;
}

/* aタグの場合 */
.c-button2 {
  text-decoration: none;
  background: -webkit-gradient(linear, left top, right top, from(#da70d6), to(#ba55d3));
  background: linear-gradient(left, #da70d6, #ba55d3);
  border-radius: 50px;
  color: #fff;
  display: inline-block;
  max-width: 315px;
  padding: 18px 0;
  position: relative;
  width: 100%;
  font-size: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.c-button2::after {
  border-right: 2px solid #fff;
  border-top: 2px solid #fff;
  content: "";
  display: block;
  height: 10px;
  position: absolute;
  right: 20px;
  top: 42%;
  -webkit-transform: rotate(45deg);
  transform: rotate(45deg);
  width: 10px;
}

.c-button1:hover,
.c-button2:hover{
  cursor: pointer;
}

作りたいもの②

ホバーすると背景が左から右へ流れるボタン

See the Pen Untitled by Tomoka (@tomokoro) on CodePen.

HTML

<a href="#" class="btn">
  <span class="btn__bg">
    <span class="btn__text">ボタン</span>     </span>
</a>

CSS

HTML CSSResult Skip Results Iframe
EDIT ON

.btn {
  display: inline-block;
  max-width: 202px;
  width: 100%;
  position: relative;
  z-index: 100;
  text-align: center;
}

.btn::after {
  display: inline-block;
  content: '';
  background: white;
  border: 1px solid red;
  position: absolute;
  top: 4px;
  right: -4px;
  width: 200px;
  height: 100%;
  border: 1px solid red;
  z-index: -1;
}

.btn__bg {
  max-width: 200px;
  width: 100%;
  font-size: 14px;
  font-weight: normal;
  line-height: calc(22/14);
  color: white;
  background-color: red;
  border: 1px solid red;
  padding-top: 15px;
  padding-bottom: 15px;
  display: inline-block;
  z-index: 100;
}

.btn__bg::before {
  display: block;
  background: white;
  border: 1px solid red;
  position: absolute;
  top: 0;
  left: 0;
  content: '';
  width: 100%;
  height: 100%;
  transform: scale(0, 1);
  transform-origin: left top;
  transition: .3s cubic-bezier(0.45, 0, 0.55, 1);
}

.btn:hover {
  color: ;
  opacity: 1;
}

.btn:hover .btn__bg {
  color: red;
  opacity: 1;
}

.btn:hover .btn__bg::before {
  transform: scale(1, 1);
  opacity: 1;
}

.btn__text {
  position: relative;
  display: inline-flex;
  align-items: center;
}
よかったらシェアしてね!
  • URLをコピーしました!
目次