Skip to content

Instantly share code, notes, and snippets.

@jensgro
Last active August 29, 2015 14:10
Show Gist options
  • Save jensgro/41158bf607f2fd4b797f to your computer and use it in GitHub Desktop.
Save jensgro/41158bf607f2fd4b797f to your computer and use it in GitHub Desktop.
Google/Nexus Style Buttons using SCSS
<link href="//maxcdn.bootstrapcdn.com/font-awesome/4.2.0/css/font-awesome.min.css" rel="stylesheet">
</a><div class="shopping-cartTag"><a href="#"><i class="fa fa-shopping-cart fa-3x"></i></a></div>
<a href="#" class="button blue-button" class="ripplelink">
<h3 class="button-title">Product One</h3>
<div class="button-description">The item description goes here</div>
<div class="button-price">$5</div>
<div class="button-arrow"></div>
</a>
<a href="#" class="button red-button" class="ripplelink">
<h3 class="button-title">Product Two</h3>
<div class="button-description">The item description goes here</div>
<div class="button-price">$10</div>
<div class="button-arrow"></div>
</a>
<a href="#" class="button yellow-button" class="ripplelink">
<h3 class="button-title">Product Three</h3>
<div class="button-description">The description of the item can be pretty long.</div>
<div class="button-price">$15</div>
<div class="button-arrow"></div>
</a>
<a href="#" class="button green-button" class="ripplelink">
<h3 class="button-title">Product Four</h3>
<div class="button-description">It can fit over 50 characters, depending on the price</div>
<div class="button-price">$20</div>
<div class="button-arrow"></div>
</a>
// ----
// Sass (v3.3.14)
// Compass (v1.0.1)
// ----
@import url(http://fonts.googleapis.com/css?family=Roboto:400,400italic,500,500italic,700,900,700italic,900italic);
html { background: #999; }
body {
position:relative;
width: 420px;
margin: 0 auto;
margin-top: 50px;
background: #eee;
padding: 20px;
font-family: sans-serif;
font-size: 12px;
border-radius:5px;
}
.button {
display: block;
background: white;
padding: 20px;
position: relative;
color: #999;
box-shadow: 0 2px 1px -1px rgba(black, 0.2), 0 -5px 0 0 rgba(black, 0.1) inset;
border-radius: 10px;
overflow: hidden;
margin: 0 0 0.75rem 0;
text-decoration: none;
&::before {
width: 10px;
position: absolute;
left: 0;
top: 0;
height: 100%;
content: '';
background: red;
box-shadow: 0 -5px 0 0 rgba(black, 0.2) inset;
border-bottom-left-radius: 10px;
}
&:hover {
display: block;
background: white;
padding: 20px;
position: relative;
color: #999;
overflow: hidden;
margin: 0 0 0.75rem 0;
text-decoration: none;
box-shadow: 0 -5px 0 0 rgba(black, 0.2) inset;
}
}
.blue-button::before { background: #0266C8; }
.red-button::before { background: #F90101; }
.yellow-button::before { background: #F2B50F; }
.green-button::before { background: #00933B; }
.button-title {
font-family: 'Roboto', sans-serif;
font-weight: bold;
color: black;
font-size: 1.2rem;
margin: 0 0 0.5rem 0;
}
.button-arrow {
background: #f5f5f5;
position: absolute;
right: 0;
top: 0;
height: 100%;
width: 40px;
text-align: center;
color: #e3e3e8;
text-shadow: -1px 0 1px rgba(white, 1);
box-shadow: 0 -5px 0 0 rgba(black, 0.1) inset;
font-size: 2rem;
&:before {
content: "";
display: inline-block;
height: 100%;
vertical-align: middle;
}
&::after { content: ">"; }
}
.button-price {
position: absolute;
right: 45px;
top: 0;
height: 100%;
font-size: 2.2rem;
font-family: 'Roboto', sans-serif;
font-weight: bold;
&:before {
content: "";
display: inline-block;
height: 100%;
vertical-align: middle;
}
}
.shopping-cartTag {
position: absolute;
width: 100px;
height: 60px;
top: 0;
left: 420px;
background-color:#0266C8;
border-radius: 10px;
z-index: -10;
i {
position: absolute;
width: 50px;
height: 50px;
color: white;
margin-left: 50px;
margin-top: 11px;
}
&:hover {
position: absolute;
width: 100px;
height: 60px;
top: 0;
left: 430px;
background-color:#0266C8;
border-radius: 10px;
z-index: -10;
-webkit-transition: all 1s; /* For Safari 3.1 to 6.0 */
transition: all 1s;
}
}
@import url(http://fonts.googleapis.com/css?family=Roboto:400,400italic,500,500italic,700,900,700italic,900italic);
html {
background: #999;
}
body {
position: relative;
width: 420px;
margin: 0 auto;
margin-top: 50px;
background: #eee;
padding: 20px;
font-family: sans-serif;
font-size: 12px;
border-radius: 5px;
}
.button {
display: block;
background: white;
padding: 20px;
position: relative;
color: #999;
box-shadow: 0 2px 1px -1px rgba(0, 0, 0, 0.2), 0 -5px 0 0 rgba(0, 0, 0, 0.1) inset;
border-radius: 10px;
overflow: hidden;
margin: 0 0 0.75rem 0;
text-decoration: none;
}
.button::before {
width: 10px;
position: absolute;
left: 0;
top: 0;
height: 100%;
content: '';
background: red;
box-shadow: 0 -5px 0 0 rgba(0, 0, 0, 0.2) inset;
border-bottom-left-radius: 10px;
}
.button:hover {
display: block;
background: white;
padding: 20px;
position: relative;
color: #999;
overflow: hidden;
margin: 0 0 0.75rem 0;
text-decoration: none;
box-shadow: 0 -5px 0 0 rgba(0, 0, 0, 0.2) inset;
}
.blue-button::before {
background: #0266C8;
}
.red-button::before {
background: #F90101;
}
.yellow-button::before {
background: #F2B50F;
}
.green-button::before {
background: #00933B;
}
.button-title {
font-family: 'Roboto', sans-serif;
font-weight: bold;
color: black;
font-size: 1.2rem;
margin: 0 0 0.5rem 0;
}
.button-arrow {
background: #f5f5f5;
position: absolute;
right: 0;
top: 0;
height: 100%;
width: 40px;
text-align: center;
color: #e3e3e8;
text-shadow: -1px 0 1px white;
box-shadow: 0 -5px 0 0 rgba(0, 0, 0, 0.1) inset;
font-size: 2rem;
}
.button-arrow:before {
content: "";
display: inline-block;
height: 100%;
vertical-align: middle;
}
.button-arrow::after {
content: ">";
}
.button-price {
position: absolute;
right: 45px;
top: 0;
height: 100%;
font-size: 2.2rem;
font-family: 'Roboto', sans-serif;
font-weight: bold;
}
.button-price:before {
content: "";
display: inline-block;
height: 100%;
vertical-align: middle;
}
.shopping-cartTag {
position: absolute;
width: 100px;
height: 60px;
top: 0;
left: 420px;
background-color: #0266C8;
border-radius: 10px;
z-index: -10;
}
.shopping-cartTag i {
position: absolute;
width: 50px;
height: 50px;
color: white;
margin-left: 50px;
margin-top: 11px;
}
.shopping-cartTag:hover {
position: absolute;
width: 100px;
height: 60px;
top: 0;
left: 430px;
background-color: #0266C8;
border-radius: 10px;
z-index: -10;
-webkit-transition: all 1s;
/* For Safari 3.1 to 6.0 */
transition: all 1s;
}
<link href="//maxcdn.bootstrapcdn.com/font-awesome/4.2.0/css/font-awesome.min.css" rel="stylesheet">
</a><div class="shopping-cartTag"><a href="#"><i class="fa fa-shopping-cart fa-3x"></i></a></div>
<a href="#" class="button blue-button" class="ripplelink">
<h3 class="button-title">Product One</h3>
<div class="button-description">The item description goes here</div>
<div class="button-price">$5</div>
<div class="button-arrow"></div>
</a>
<a href="#" class="button red-button" class="ripplelink">
<h3 class="button-title">Product Two</h3>
<div class="button-description">The item description goes here</div>
<div class="button-price">$10</div>
<div class="button-arrow"></div>
</a>
<a href="#" class="button yellow-button" class="ripplelink">
<h3 class="button-title">Product Three</h3>
<div class="button-description">The description of the item can be pretty long.</div>
<div class="button-price">$15</div>
<div class="button-arrow"></div>
</a>
<a href="#" class="button green-button" class="ripplelink">
<h3 class="button-title">Product Four</h3>
<div class="button-description">It can fit over 50 characters, depending on the price</div>
<div class="button-price">$20</div>
<div class="button-arrow"></div>
</a>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment