본문 바로가기
STUDY/HTML, CSS

FreeCodeCamp: Button Style CSS3

by Sine 1982 2021. 5. 14.

<Facebook Button Style>

 

<p>Facebook Style</p>
    <button type="button" name="button" class="facebook-style-btn facebook-style-dark">Button Dark</button>
    <button type="button" name="button" class="facebook-style-btn facebook-style-light">Button Light</button>

 

.facebook-style-btn {
  border-radius: 2px;
  font-size: 0.9rem;
  padding: 6px 12px;
}
.facebook-style-dark {
  -moz-outline-radius: inset 0 1px 0 0 #4d73bf;
  -webkit-box-shadow: inset 0 1px 0 0 #4d73bf;
  box-shadow: inset 0 1px 0 0 #4d73bf;
  background: #4267b2;
  border: solid 1px #4267b2;
  color: white;
  text-shadow: 0 1px 0 #3359a5;
}
.facebook-style-dark:hover {
  background: #2b54a7;
}
.facebook-style-dark:active {
  background: #1d4698;
  border-color: #1d4698;
}
.facebook-style-light {
  background: #f6f7f9;
  border: solid 1px #ced0d4;
  color: #4b4f56;
}
.facebook-style-light:hover {
  background: #e9ebee;
}
.facebook-style-light:active {
  background: #d8dade;
  border-color: #d8dade;
}

output

https://output.jsbin.com/nekoqaxoci/1

 

JS Bin

 

output.jsbin.com

 

 

<3D Button Style>

 

<p>3D Buttons</p>
    <button type="button" name="button" class="btn-3d-style-1">3D Button 1</button>
    <button type="button" name="button" class="btn-3d-style-2">Circle!</button>

 

.btn-3d-style-1 {
  position: relative;
  background: orangered;
  border: none;
  color: white;
  padding: 15px 24px;
  font-size: 1.4rem;
  box-shadow: -6px 6px 0 hsl(16, 100%, 30%); /*그림자*/
  outline: none;
}
.btn-3d-style-1:hover {
  background: hsl(16, 100%, 45%);
}
.btn-3d-style-1:active {
  background: hsl(16, 100%, 40%);
  top: 3px;
  left: -3px;
  box-shadow: -3px 3px 0;
}
.btn-3d-style-1::before {
  position: absolute;
  display: block;
  content: "";
  height: 0;
  width: 0;
  /*버튼 그림자 엣지- 트라이엥글을 만든다. */
  border: solid 6px transparent;
  border-right: solid 6px hsl(16, 100%, 30%);
  border-left-width: 0;
  top: 0;
  left: -6px;
}
.btn-3d-style-1::after {
  position: absolute;
  display: block;
  content: "";
  height: 0;
  width: 0;
  border: solid 6px transparent;
  border-top: solid 6px hsl(16, 100%, 30%);
  border-bottom-width: 0;
  right: 0;
  bottom: -6px;
}
.btn-3d-style-1:active::before {
  border: solid 0px transparent;
  border-right: solid 0px hsl(16, 100%, 30%);
  border-left-width: 0;
  left: -3px;
}
.btn-3d-style-1:active::after {
  border: solid 0px transparent;
  border-top-width: solid 0px hsl(16, 100%, 30%);
  border-bottom-width: 0;
  left: -3px;
}
.btn-3d-style-2 {
  position: relative;
  background: #ecd300;
  background: -webkit-radial-gradient(hsl(54, 100%, 50%), hsl(54, 100%, 40%));
  background: -o-radial-gradient(hsl(54, 100%, 50%), hsl(54, 100%, 40%));
  background: -moz-radial-gradient(hsl(54, 100%, 50%), hsl(54, 100%, 40%));
  background: radial-gradient(hsl(54, 100%, 50%), hsl(54, 100%, 40%));

  font-size: 1.4rem;
  text-shadow: 0 -1px 0 #c3af07;
  color: white;
  border: solid 1px hsl(54, 100%, 20%);
  border-radius: 100%;
  height: 120px;
  width: 120px;
  z-index: 4;
  outline: none;
  box-shadow: inset 0 1px 0 hsl(54, 100%, 50%), 0 2px 0 hsl(54, 100%, 20%),
    0 3px 0 hsl(54, 100%, 18%), 0 4px 0 hsl(54, 100%, 16%),
    0 5px 0 hsl(54, 100%, 14%), 0 6px 0 hsl(54, 100%, 12%),
    0 7px 0 hsl(54, 100%, 10%), 0 8px 0 hsl(54, 100%, 8%),
    0 9px 0 hsl(54, 100%, 6%);
}
.btn-3d-style-2:hover {
  background: -webkit-radial-gradient(hsl(54, 100%, 45%), hsl(54, 100%, 34%));
  background: -o-radial-gradient(hsl(54, 100%, 45%), hsl(54, 100%, 34%));
  background: -moz-radial-gradient(hsl(54, 100%, 45%), hsl(54, 100%, 34%));
  background: radial-gradient(hsl(54, 100%, 45%), hsl(54, 100%, 34%));
}
.btn-3d-style-2:active {
  background: -webkit-radial-gradient(hsl(54, 100%, 43%), hsl(54, 100%, 33%));
  background: -o-radial-gradient(hsl(54, 100%, 43%), hsl(54, 100%, 33%));
  background: -moz-radial-gradient(hsl(54, 100%, 43%), hsl(54, 100%, 33%));
  background: radial-gradient(hsl(54, 100%, 43%), hsl(54, 100%, 33%));

  top: 2px;
  box-shadow: inset 0 1px 0 hsl(54, 100%, 50%), 0 2px 0 hsl(54, 100%, 20%),
    0 3px 0 hsl(54, 100%, 18%), 0 4px 0 hsl(54, 100%, 16%),
    0 5px 0 hsl(54, 100%, 14%), 0 6px 0 hsl(54, 100%, 12%),
    0 7px 0 hsl(54, 100%, 10%);
}

output

https://output.jsbin.com/levamarovi/1

 

JS Bin

 

output.jsbin.com

 

 

<Gradient bordered Button Style>

 

<p>Gradient bordered buttons</p>
    <button type="button" name="button" class="gradient-btn-1">Gradient button 1</button>
    <button type="button" name="button" class="gradient-btn-2">Gradient button 2</button>

 

.gradient-btn-1 {
  position: relative;
  z-index: 1;
  display: inline-block;
  padding: 20px 40px;
  font-size: 1.4rem;
  box-sizing: border-box;
  background-color: #e7eef1;
  border: solid 10px transparent;
  border-image: linear-gradient(to top right, orangered, yellow);
  border-image-slice: 1;
  color: orangered;
  transition: all 0.3s ease-in-out;
}
.gradient-btn-1:hover {
  background-image: linear-gradient(to top right, orangered, yellow);
  color: white;
}
.gradient-btn-2 {
  position: relative;
  z-index: 1;
  display: inline-block;
  padding: 20px 40px;
  font-size: 1.4rem;
  box-sizing: border-box;
  background-color: #e7eef1;
  border: solid 4px transparent;
  border-image: linear-gradient(to right, orangered, transparent);
  border-image-slice: 1;
  color: orangered;
  transition: all 0.3s ease;
}
.gradient-btn-2:hover {
  background-image: linear-gradient(to right, orangered, transparent);
  color: white;
  border-right-style: none;
}

output

https://output.jsbin.com/casaxakevi/1

 

JS Bin

Gradient bordered buttons Gradient button 1 Gradient button 2

output.jsbin.com

 

 

<Animated Button Style>

 

<p>Toggle Switch UI buttons</p>
    <label for="toggle1" class="toggle-1">
      <input type="checkbox" id="toggle1" class="toggle-1_input" />
      <span class="toggle-1_btn"></span>
    </label>
    <label for="toggle2" class="toggle-2">
      <input type="checkbox" id="toggle2" class="toggle-2_input" />
      <span class="toggle-2_btn">Glick me to activate</span>
    </label>

 

.animated-btn-1 {
  position: relative;
  display: inline-block;
  padding: 20px 40px;
  font-size: 1.4rem;
  background-color: #00b3b4;
  background-image: url(pattern.png);
  background-size: 40px 40px;
  border: solid 1px #555;
  color: white;
  transition: all ease 0.3s;
}
.animated-btn-1:hover {
  animation: loading-button-animation 2s linear infinite;
}
@keyframes loading-button-animation {
  from {
    background-position: 0 0;
  }
  to {
    background-position: 40px 0;
  }
}
.animated-btn-2 {
  position: relative;
  display: inline-block;
  padding: 20px 40px;
  font-size: 1.4rem;
  background-color: #00b3b4;
  background-size: 40px 40px;
  border: solid 1px #555;
  color: white;
  transition: all ease 0.3s;
}
.animated-btn-2::after {
  position: absolute;
  top: 30%;
  right: 0.6em;
  content: ">";
  transition: all ease 0.3s;
  opacity: 0;
}
.animated-btn-2:hover {
  padding: 20px 60px 20px 20px;
} /* 패딩 만으로도 애니메이션 효과를 줄 수 있다*/
.animated-btn-2:hover::after {
  right: 1.2em;
  opacity: 1;
}

output

https://output.jsbin.com/povosipuhe/1

 

JS Bin

 

output.jsbin.com

 

 

<Toggle Switch UI Button Style>

 

 <p>Toggle Switch UI buttons</p>
    <label for="toggle1" class="toggle-1">
      <input type="checkbox" id="toggle1" class="toggle-1_input" />
      <span class="toggle-1_btn"></span>
    </label>
    <label for="toggle2" class="toggle-2">
      <input type="checkbox" id="toggle2" class="toggle-2_input" />
      <span class="toggle-2_btn">Glick me to activate</span>
    </label>

 

.toggle-1 {
  font-family: Arial, Helvetica, sans-serif;
  display: inline-block;
  vertical-align: top;
  margin: 0 15px 0 0;
}
.toggle-1_input {
  display: none;
}
.toggle-1_btn {
  position: relative;
  display: inline-block;
  font-size: 1rem;
  line-height: 20px;
  text-transform: uppercase;
  background-color: #f2395a;
  border: solid 1px #f2395a;
  color: white;
  width: 80px;
  height: 30px;
  transition: all 0.3s ease;
  cursor: pointer;
}
.toggle-1_btn::before {
  position: absolute;
  top: 5px;
  left: 40px;
  content: "off";
  display: inline-block;
  height: 20px;
  padding: 0 3px;
  background: white;
  color: #f2395a;
  transition: all 0.3s ease;
}
.toggle-1_input:checked + .toggle-1_btn /*제이슨 시블링 토글*/ {
  background: #00b3b4;
  border: solid 1px #00b3b4;
}
.toggle-1_input:checked + .toggle-1_btn::before {
  left: 5px;
  content: "on";
  color: #00b3b4;
}
.toggle-2 {
  font-family: Arial, Helvetica, sans-serif;
  font-size: 0.8rem;
  display: inline-block;
  vertical-align: top;
  margin: 0 15px 0 0;
}
.toggle-2_input {
  display: none;
}
.toggle-2_btn {
  position: relative;
  display: inline-block;
  line-height: 20px;
  text-transform: uppercase;
  background: white;
  color: #aaa;
  border: solid 1px #ccc;
  padding: 5px 10px 5px 30px;
  transition: all 0.3s ease;
  cursor: pointer;
}
.toggle-2_btn::before {
  position: absolute;
  top: 10px;
  left: 10px;
  display: inline-block;
  width: 10px;
  height: 10px;
  background: #ccc;
  content: "";
  transition: all 0.3s ease;
  border-radius: 100%;
}
.toggle-2_input:checked + .toggle-2_btn {
  background: #00b3b4;
  border-color: #00b3b4;
  color: white;
}
.toggle-2_input:checked + .toggle-2_btn::before {
  background-color: white;
}

output

https://output.jsbin.com/rarinadeni/1

 

JS Bin

 

output.jsbin.com

 


 

 

프리 코드 캠프(Free Code Camp)를 통해 CSS3 공부하기.

Author: Brad Hussey

www.youtube.com/playlist?list=PLWKjhJtqVAbl1AfjiGyYxwpdAPi5v-1OU

 

CSS3 in 30 Days

 

www.youtube.com

 

 

 

 

 

 

 

'STUDY > HTML, CSS' 카테고리의 다른 글

CSS Flexbox  (0) 2021.02.19
CSS display, position  (0) 2021.01.20
CSS Basic  (0) 2021.01.20
HTML Basic  (0) 2021.01.20

댓글