Skip to content

Instantly share code, notes, and snippets.

@Illizion
Last active January 19, 2018 18:22
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 Illizion/b8dd28fd21983a668a49ef6a171a4d61 to your computer and use it in GitHub Desktop.
Save Illizion/b8dd28fd21983a668a49ef6a171a4d61 to your computer and use it in GitHub Desktop.
semantic OR button groups for bootstrap
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">
<div class="btn-group choice mt-5">
<button class="btn btn-danger" role="button">Cancel</button>
<div class="or"></div>
<button class="btn btn-success" role="button">Save</button>
</div>
> 1%
last 2 versions
// ----
// Sass (v3.4.21)
// Compass (v1.0.3)
// ----
$or-btn-padding: 1rem;
.btn-group.choice{
&:first-child{
padding-right: $or-btn-padding;
}
.or {
position: relative;
width: 0.3em;
height: 2.57142857em;
z-index: 3;
&:before{
position: absolute;
text-align: center;
border-radius: 500rem;
content: 'or';
top: 50%;
left: 50%;
background-color: #FFFFFF;
text-shadow: none;
margin-top: -0.89285714em;
margin-left: -0.89285714em;
width: 1.78571429em;
height: 1.78571429em;
line-height: 1.78571429em;
color: rgba(0, 0, 0, 0.4);
font-style: normal;
font-weight: bold;
box-shadow: 0px 0px 0px 1px transparent inset;
}
&[data-text]:before {
content: attr(data-text);
}
}
&:last-child{
padding-left: $or-btn-padding;
}
}
.btn-group.choice:first-child { padding-right: 1rem; }
.btn-group.choice .or { position: relative; width: 0.3em; height: 2.57142857em; z-index: 3; }
.btn-group.choice .or:before { position: absolute; text-align: center; border-radius: 500rem; content: 'or'; top: 50%; left: 50%; background-color: #FFFFFF; text-shadow: none; margin-top: -0.89285714em; margin-left: -0.89285714em; width: 1.78571429em; height: 1.78571429em; line-height: 1.78571429em; color: rgba(0, 0, 0, 0.4); font-style: normal; font-weight: bold; box-shadow: 0px 0px 0px 1px transparent inset; }
.btn-group.choice .or[data-text]:before { content: attr(data-text); }
.btn-group.choice:last-child { padding-left: 1rem; }
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">
<div class="btn-group choice mt-5">
<button class="btn btn-danger" role="button">Cancel</button>
<div class="or"></div>
<button class="btn btn-success" role="button">Save</button>
</div>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment