CSS Buttons

ஒரு data-வை ஒரு page-லிருந்து மற்றொரு page-க்கு அனுப்ப button ஒரு switch control-ஆக பயன்படுகிறது. ஏனெனில் பெரும்பாலும் button-ஐ, click செய்த பிறகே ஒரு data-வானது அங்கிருந்து புரபடுகிறது. ஆகையால் தான் இது ஒரு switch control ஆக கருதபடுகிறது.

button-ஐ பலவிதங்களில் நமது விருப்பம்போல் அதன் வடிவத்தை மாற்றி அமைத்துக்கொள்ள முடியும். பின்வரும் ஒவொரு examples-லில் அதை விரிவாக காணலாம்.

Basic Button Styling

.button {
    background-color: #FF6600;
    border: none;
    color: white;
    padding: 15px 32px;
    text-align: center;
    text-decoration: none;
    display: inline-block;
    font-size: 16px;
    margin: 4px 2px;
    cursor: pointer;
}
Link Button

Button Colors

Use the background-color property to change the background color of a button:

.bColor {
    background-color: #1b434f; 
    border: none;
    color: white;
    padding: 15px 32px;
    text-align: center;
    text-decoration: none;
    display: inline-block;
    font-size: 16px;
    margin: 4px 2px;
    cursor: pointer;
}

.button1 {background-color: #FF6600;} /* Orange */
.button2 {background-color: #008CBA;} /* Blue */
.button3 {background-color: #f44336;} /* Red */ 
.button4 {background-color: #e7e7e7; color: black;} /* Gray */ 
.button5 {background-color: #555555;} /* Black */

Button Sizes

font-size மற்றும் padding values-ஐ மாற்றுவதன் மூலம் button size விரிவுபடுத்த முடியும்.

.size {
    background-color: #FF6600; /* Orange */
    border: none;
    color: white;
    padding: 15px 32px;
    text-align: center;
    text-decoration: none;
    display: inline-block;
    margin: 4px 2px;
    cursor: pointer;
}

.size1 {font-size: 10px;}
.size2 {font-size: 12px;}
.size3 {font-size: 16px;}
.size4 {font-size: 20px;}
.size5 {font-size: 24px;}

Rounded Buttons

border-radius-ஐ பயன்படுத்தினால் round corners-கொண்ட button-ஐ உருவாகிகொள்ளலாம்

.round {
    background-color: #FF6600; /* Orange */
    border: none;
    color: white;
    padding: 20px;
    text-align: center;
    text-decoration: none;
    display: inline-block;
    font-size: 16px;
    margin: 4px 2px;
    cursor: pointer;
}

.round1 {border-radius: 2px;}
.round2 {border-radius: 4px;}
.round3 {border-radius: 8px;}
.round4 {border-radius: 12px;}
.round5 {border-radius: 50%;}

Colored Borders

bordered button-ஐ பெறுவதற்கு border-color-ஐ பயன்படுத்துங்கள்.

.color {
    background-color: #FF6600; /* Orange */
    border: none;
    color: white;
    padding: 15px 32px;
    text-align: center;
    text-decoration: none;
    display: inline-block;
    font-size: 16px;
    margin: 4px 2px;
    cursor: pointer;
}

.color1 {
    background-color: white; 
    color: black; 
    border: 2px solid #FF6600;
}

.color2 {
    background-color: white; 
    color: black; 
    border: 2px solid #008CBA;
}

.color3 {
    background-color: white; 
    color: black; 
    border: 2px solid #f44336;
}

.color4 {
    background-color: white;
    color: black;
    border: 2px solid #e7e7e7;
}

.color5 {
    background-color: white;
    color: black;
    border: 2px solid #555555;
}

Hoverable Buttons

"hover" effect-ஐ animate செய்ய transition-duration property-ஐ பயன்படுத்துங்கள்

.bhover {
    background-color: #FF6600; /* Orange */
    border: none;
    color: white;
    padding: 16px 32px;
    text-align: center;
    text-decoration: none;
    display: inline-block;
    font-size: 16px;
    margin: 4px 2px;
    -webkit-transition-duration: 0.4s; /* Safari */
    transition-duration: 0.4s;
    cursor: pointer;
}

.bhover {
    background-color: white; 
    color: black; 
    border: 2px solid #FF6600;
}

.bhover:hover {
    background-color: #FF6600;
    color: white;
}

.bhover2 {
    background-color: white; 
    color: black; 
    border: 2px solid #008CBA;
	}

.bhover2:hover {
    background-color: #008CBA;
    color: white;
}

.bhover3 {
    background-color: white; 
    color: black; 
    border: 2px solid #f44336;
}

.bhover3:hover {
    background-color: #f44336;
    color: white;
}

.bhover4 {
    background-color: white;
    color: black;
    border: 2px solid #e7e7e7;
}

.bhover4:hover {background-color: #e7e7e7;}

.bhover5 {
    background-color: white;
    color: black;
    border: 2px solid #555555;
}

.bhover5:hover {
    background-color: #555555;
    color: white;
}

Disabled Buttons

Use the opacity property to add transparency to a button (creates a "disabled" look).

Note: You can also add the cursor property with a value of "not-allowed", which will display a "no parking sign" when you mouse over the button.
.bdisable {
    background-color: #FF6600; /* Orange */
    border: none;
    color: white;
    padding: 15px 32px;
    text-align: center;
    text-decoration: none;
    display: inline-block;
    font-size: 16px;
    margin: 4px 2px;
    cursor: pointer;
}

.disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

Button Groups

Remove margins and add float:left to each button to create a button group:

.btn-group .bgroup {
    background-color: #1b434f; /* Orange */
    border: none;
    color: white;
    padding: 15px 32px;
    text-align: center;
    text-decoration: none;
    display: inline-block;
    font-size: 16px;
    cursor: pointer;
    float: left;
	}

.btn-group .bgroup:hover {
    background-color: #FF6600;
}

Button on Image

.container {
    position: relative;
    width: 100%;
    max-width: 400px;
}

.container img {
    width: 100%;
    height: auto;
}

.container .btn {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    -ms-transform: translate(-50%, -50%);
    background-color: #f1f1f1;
    color: black;
    font-size: 16px;
    padding: 16px 30px;
    border: none;
    cursor: pointer;
    border-radius: 5px;
    text-align: center;
}

.container .btn:hover {
    background-color: black;
    color: white;
}
Snow

Animated Buttons

.aniButton {
    display: inline-block;
    border-radius: 4px;
    background-color: #f4511e;
    border: none;
    color: #FFFFFF;
    text-align: center;
    font-size: 28px;
    padding: 20px;
    width: 200px;
    transition: all 0.5s;
    cursor: pointer;
    margin: 5px;
}

.aniButton span {
    cursor: pointer;
    display: inline-block;
    position: relative;
    transition: 0.5s;
}

.aniButton span:after {
    content: '\00bb';
    position: absolute;
    opacity: 0;
    top: 0;
    right: -20px;
    transition: 0.5s;
}

.aniButton:hover span {
    padding-right: 25px;
}

.aniButton:hover span:after {
    opacity: 1;
    right: 0;
} 
.aniButton2 {
    position: relative;
    background-color: #FF6600;
    border: none;
    font-size: 28px;
    color: #FFFFFF;
    padding: 20px;
    width: 200px;
    text-align: center;
    -webkit-transition-duration: 0.4s; /* Safari */
    transition-duration: 0.4s;
    text-decoration: none;
    overflow: hidden;
    cursor: pointer;
}

.aniButton2:after {
    content: "";
    background: #f1f1f1;
    display: block;
    position: absolute;
    padding-top: 300%;
    padding-left: 350%;
    margin-left: -20px !important;
    margin-top: -120%;
    opacity: 0;
    transition: all 0.8s;
}

.aniButton2:active:after {
    padding: 0;
    margin: 0;
    opacity: 1;
    transition: 0s;
}

Comments