Skip to content

Instantly share code, notes, and snippets.

@carloscasalar
Last active May 5, 2020 08:55
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 carloscasalar/d8fc2768f84075d6f58c to your computer and use it in GitHub Desktop.
Save carloscasalar/d8fc2768f84075d6f58c to your computer and use it in GitHub Desktop.
Html5, css tips

CSS

Add carets next after an element

https://codepen.io/adrianparr/pen/qdbmE

<a href="#" class="arrow-button"><span class="arrow-left">Left</span></a>
<a href="#" class="arrow-button"><span class="arrow-right">Right</span></a>
<a href="#" class="arrow-button"><span class="arrow-down">Down</span></a>
<a href="#" class="arrow-button"><span class="arrow-up">Up</span></a>
body {
  font-family: Helvetica, Arial, sans-serif;
  font-weight: 600;
  font-size: 3em;
}

a.arrow-button {
  margin: 1em auto;
  width: 280px;
  text-align: center;
  background-color: #eee;
  padding: 0.5em 0;
  display: block;
  color: #333;
  text-decoration: none;
  text-transform: uppercase;
  transition: all 0.2s;
  box-shadow: 1px 1px 5px 0px rgba(50, 50, 50, 0.6);
  border-radius: 8px;
  &:hover {
    color: #eee;
    background-color: #333;
  }
}

.arrow-left {
  &:before {
    content: '\25c4';
    padding-right: 0.5em;
  }
}

.arrow-right {
  &:after {
    content: '\25ba';
    padding-left: 0.5em;
  }
}

.arrow-down {
  &:after {
    content: '\25bc';
    padding-left: 0.5em;
  }
}
.arrow-up {
  &:after {
    content: '\25b2';
    padding-left: 0.5em;
  }
}

Avatar initials

https://codepen.io/AllThingsSmitty/pen/dWmmQp

<div class="circle">
  <span class="initials">MS</span>
</div>
/* http://caniuse.com/#search=variables */
:root {
  --avatar-size: 18rem;
  /* change this value anything, e.g., 100px, 10rem, etc. */
}

.circle {
  background-color: #ccc;
  border-radius: 50%;
  height: var(--avatar-size);
  text-align: center;
  width: var(--avatar-size);
}

.initials {
  font-size: calc(var(--avatar-size) / 2); /* 50% of parent */
  line-height: 1;
  position: relative;
  top: calc(var(--avatar-size) / 4); /* 25% of parent */
}





html, body {
  height: 100%;
}

body {
  display: -webkit-box;
  display: -ms-flexbox;
  display: flex;
  -webkit-box-align: center;
  -ms-flex-align: center;
  align-items: center;
  -webkit-box-pack: center;
  -ms-flex-pack: center;
  font-family: sans-serif;
  justify-content: center;
  margin: 0;
}

CSS tools and framewors

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment