Skip to content

Instantly share code, notes, and snippets.

@atularvind
Created August 20, 2017 06:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save atularvind/de8bbd78de751b7078a99629ceff011c to your computer and use it in GitHub Desktop.
Save atularvind/de8bbd78de751b7078a99629ceff011c to your computer and use it in GitHub Desktop.
HTML Switch Inspiration with text in bootstrap
<!DOCTYPE html>
<html lang="en">
<head>
<title>Bootstrap Example</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<style type="text/css">
.switch {
position: relative;
display: inline-block;
width: 60px;
height: 25px;
}
.switch input {display:none;}
.slider {
position: absolute;
cursor: pointer;
top: 0;
left: 0;
right: 0;
bottom: 0;
background-color: #C50C11;
-webkit-transition: .4s;
transition: .4s;
}
input:checked + .slider {
background-color: #2F7D32;
}
.on
{
display: none;
}
.on, .off
{
color: white;
position: absolute;
transform: translate(-50%,-50%);
top: 49%;
left: 50%;
font-size: 10px;
font-family: Verdana, sans-serif;
}
input:checked+ .slider .on
{display: block;}
input:checked + .slider .off
{display: none;}
.slider.round {
border-radius: 3px;
}
</style>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.0/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
</head>
<body>
<div class="container">
<h1>Atul Arvind</h1>
<p>Html Switch example in Bootstrap .</p>
<label class="switch"><input type="checkbox" id="togBtn"><div class="slider round">
<span class="on">Excel</span><span class="off">PDF</span></div></label>
</div>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment