Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URLs added here will be added as <link>s in order, and before the CSS in the editor. You can use the CSS from another Pen by using its URL and the proper URL extension.

+ add another resource

JavaScript

Babel includes JSX processing.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource

Packages

Add Packages

Search for and use JavaScript packages from npm here. By selecting a package, an import statement will be added to the top of the JavaScript editor for this package.

Behavior

Auto Save

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.

HTML

              
                <main>

  <p>
    <a href="http://adrianroselli.com/2016/06/punch-out-avatar.html" target="_top">I've written a post with better examples and more features.</a>
  </p>
  
  <p>
    This probably reflects a standard bio card thing. The image is centered by default. The background color is semi-transparent so you can see that there are no overlaps. The page texture also shows through, so this isn't a fake punch-out effect.
  </p>

  <p class="bio">
    Lorem ipsum dolor sit amet, consectetur adipiscing elit. Cras vitae tempor dolor, et pulvinar nulla. Nunc nibh eros, feugiat et vehicula a, tincidunt nec augue.
    <span class="pic"></span>
    <span class="circle"></span>
  </p>

  <p>
    You can scale the entire box just by changing the text size. The image, radius, punch-out, etc. all scale with it.
  </p>

  <p class="bio two">
    Lorem ipsum dolor sit amet, consectetur adipiscing elit. Cras vitae tempor dolor, et pulvinar nulla. Nunc nibh eros, feugiat et vehicula a, tincidunt nec augue.
    <span class="pic"></span>
    <span class="circle"></span>
  </p>

  <p>
    Change the background color for your site. Account for different avatar images that maybe you don't want to scale to completely fill the circle.
  </p>

  <p class="bio three">
    Lorem ipsum dolor sit amet, consectetur adipiscing elit. Cras vitae tempor dolor, et pulvinar nulla. Nunc nibh eros, feugiat et vehicula a, tincidunt nec augue.
    <span class="pic"></span>
    <span class="circle"></span>
  </p>

  <p>
    While the box has a practical maximum size based on the font size you choose, it also doesn't need to fill the entire width of the page (container).

    <p class="bio four">
      Lorem ipsum dolor sit amet, consectetur adipiscing elit. Cras vitae tempor dolor, et pulvinar nulla. Nunc nibh eros, feugiat et vehicula a, tincidunt nec augue.
      <span class="pic"></span>
      <span class="circle"></span>
    </p>

    <p>
      Maybe you don't want the image centered. That's cool. In this case I put the edge of the punch-out in line with the edge of the text. Because alignment, or some designery stuff like that.
    </p>

    <p class="bio five">
      Lorem ipsum dolor sit amet, consectetur adipiscing elit. Cras vitae tempor dolor, et pulvinar nulla. Nunc nibh eros, feugiat et vehicula a, tincidunt nec augue.
      <span class="pic"></span>
      <span class="circle"></span>
    </p>

    <p>
      What's that? You want a bigger image? Ugh. Fine.
    </p>

    <p class="bio six">
      Lorem ipsum dolor sit amet, consectetur adipiscing elit. Cras vitae tempor dolor, et pulvinar nulla. Nunc nibh eros, feugiat et vehicula a, tincidunt nec augue.
      <span class="pic"></span>
      <span class="circle"></span>
    </p>

    <p>
      I suppose now you want a quote thinger with the image hanging off the bottom. I'll even scale it up so you can see more image/text overlap.
    </p>

    <p class="bio seven">
      Lorem ipsum dolor sit amet, consectetur adipiscing elit. Cras vitae tempor dolor, et pulvinar nulla. Nunc nibh eros, feugiat et vehicula a, tincidunt nec augue.
      <span class="pic"></span>
      <span class="circle"></span>
    </p>

    <p>
      That's it. That's all I have time for. Now go make your own variations.
    </p>

    <p>
      In the interests of accessibility best practices:
    </p>
    <ul>
      <li>Pay attention to color contrast between the text and background,</li>
      <li>All of my examples assume left-to-right reading order,</li>
      <li>Do not insert any images that have text to be read or otherwise convey information,</li>
      <li>If you choose to do that anyway, consider adding some alternative text into the HTML itself and then using an off-screen technique to hide it.</li>
    </ul>

    <p>
      If that last bullet confused you, here is an example of what I mean. If you look at the HTML, you will see some text is where the image lives.
    </p>


    <blockquote class="bio eight">
      <p>
        Lorem ipsum dolor sit amet, consectetur adipiscing elit. Cras vitae tempor dolor, et pulvinar nulla. Nunc nibh eros, feugiat et vehicula a, tincidunt nec augue.
      </p>
      <p>
        Lorem ipsum dolor sit amet, consectetur adipiscing elit. Cras vitae tempor dolor, et pulvinar nulla. Nunc nibh eros, feugiat et vehicula a, tincidunt nec augue.
      </p>
      <footer>
        <span class="pic">As said by Bill Murray during some movie or another.</span>
        <span class="circle"></span>
      </footer>
    </blockquote>

    <p>
      Sorry. You probably wanted the image hanging off the box. Got it.
    </p>


    <blockquote class="bio seven">
      <p>
        Lorem ipsum dolor sit amet, consectetur adipiscing elit. Cras vitae tempor dolor, et pulvinar nulla. Nunc nibh eros, feugiat et vehicula a, tincidunt nec augue.
      </p>
      <p>
        Lorem ipsum dolor sit amet, consectetur adipiscing elit. Cras vitae tempor dolor, et pulvinar nulla. Nunc nibh eros, feugiat et vehicula a, tincidunt nec augue.
      </p>
      <footer>
        <span class="pic">As said by Bill Murray during some movie or another.</span>
        <span class="circle"></span>
      </footer>
    </blockquote>
</main>
              
            
!

CSS

              
                @import url(https://fonts.googleapis.com/css?family=Lato:400,700);
body {
  background-color: #6D695C;
  background-image: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAMAAAAoLQ9TAAAACVBMVEUAAAAAAAAAAACDY+nAAAAAA3RSTlMmDQBzGIDBAAAAG0lEQVR42uXIIQEAAADCMHj/0NdkQMws0HEeAqvwAUGJthrXAAAAAElFTkSuQmCC);
  font-size: 100%;
  color: #333;
  font-family: Lato, Arial, sans-serif;
  padding: 0;
  margin: 0;
}

main {
  display: block;
  box-sizing: border-box;
  width: 90%;
  margin: 1em auto;
  padding: 1em 2em;
  color: #000;
  background-color: rgba(204, 204, 204, .3);
  border: .07em solid rgba(0, 0, 0, .3);
  border-radius: .5em;
}


/* The layout */

.bio {
  box-sizing: border-box;
  width: 100%;
  position: relative;
  /*top: 3em;*/
  margin: 7em 0 0 0;
  padding: .25em 1.5em 1em 1.5em;
  line-height: 1.7;
  border-radius: 0 0 1em 1em;
}

.bio::before,
.bio::after {
  content: "";
  display: block;
  box-sizing: border-box;
  height: 2.1em;
  position: absolute;
  top: -2.1em;
}

.bio::before {
  left: 0;
  width: calc(50% - 3.25em);
  /*width: calc(50% - 3.24em); Use this with solid colors if IE11 is giving you trouble*/
  border-radius: 1em 0 0 0;
}

.bio::after {
  right: 0;
  width: calc(50% - 3.24em);
  /*width: calc(50% - 3.24em); Use this with solid colors if IE11 is giving you trouble*/
  border-radius: 0 1em 0 0;
}

.pic {
  position: absolute;
  width: 5.5em;
  height: 5.5em;
  top: -6em;
  left: calc(50% - 2.75em);
  border-radius: 5.5em;
  background-color: rgba(255, 255, 255, .3);
  background-position: 50% 50%;
  background-size: cover;
  background-repeat: no-repeat;
}

.circle {
  position: absolute;
  box-sizing: border-box;
  display: block;
  width: 6.5em;
  height: 2.1em;
  top: -2.1em;
  left: calc(50% - 3.25em);
  overflow: hidden;
}

.circle::after {
  position: absolute;
  content: "";
  width: 6.5em;
  height: 6.5em;
  border-radius: 6.5em;
  background: transparent;
  top: -7em;
  left: -2.5em;
  border: 2.5em solid rgba(0, 0, 0, 0.8);
}


/* Set the background and text color of the box here */

.bio,
.bio::before,
.bio::after {
  background: rgba(0, 0, 102, 0.6);
  color: #ccc;
}

.circle::after {
  border-color: rgba(0, 0, 102, 0.6);
}

.bio.three,
.bio.three::before,
.bio.three::after {
  background: rgba(0, 102, 102, 0.6);
  color: #ccc;
}

.three .circle::after {
  border-color: rgba(0, 102, 102, 0.6);
}

.bio.four,
.bio.four::before,
.bio.four::after {
  background: rgba(102, 102, 0, 0.6);
  color: #ccc;
}

.four .circle::after {
  border-color: rgba(102, 102, 0, 0.6);
}

.bio.seven,
.bio.seven::before,
.bio.seven::after {
  background: rgba(102, 0, 102, 0.6);
  color: #ccc;
}

.seven .circle::after {
  border-color: rgba(102, 0, 102, 0.6);
}


/* Set the size of the overall box by changing the font size. */

.bio.two {
  font-size: 200%;
}

.bio.seven {
  font-size: 120%;
}


/* Set the image */

.pic {
  background-image: url(https://www.fillmurray.com/200/200);
}

.two .pic {
  background-image: url(https://www.fillmurray.com/300/300);
}

.three .pic {
  background-image: url(https://www.fillmurray.com/300/100);
  background-size: contain;
}

.four .pic {
  background-image: url(https://www.fillmurray.com/400/400);
}

.five .pic {
  background-image: url(https://www.fillmurray.com/200/400);
}

.six .pic {
  background-image: url(https://www.fillmurray.com/600/600);
}

.seven .pic {
  background-image: url(https://www.fillmurray.com/250/250);
}


/* Messing with the layout */

.bio.four {
  width: 60%;
}


/* Move the pic to the left */

.five .pic {
  left: 2em;
}

.five .circle {
  left: 1.5em;
}

.bio.five::before {
  width: 1.5em;
}

.bio.five::after {
  width: calc(100% - 8em);
}


/* Larger image */

.bio.six {
  margin-top: 11.5em;
}

.six .pic {
  width: 10em;
  height: 10em;
  top: -10.5em;
  left: calc(50% - 5em);
  border-radius: 10em;
}

.six .circle {
  width: 11em;
  left: calc(50% - 5.5em);
  height: 2.6em;
  top: -2.6em;
}

.six .circle::after {
  width: 11em;
  height: 11em;
  border-radius: 11em;
  background: transparent;
  top: -11em;
  left: -2.5em;
}

.bio.six::before,
.bio.six::after {
  height: 2.6em;
  top: -2.6em;
}

.bio.six::before {
  left: 0;
  width: calc(50% - 5.5em);
}

.bio.six::after {
  right: 0;
  width: calc(50% - 5.49em);
}


/* Hang it off the bottom */

.seven {
  margin: 0 0 7em 0;
  padding: 1em 1.5em .25em 1.5em;
  border-radius: 1em 1em 0 0;
}

.seven .pic {
  right: 2em;
  left: initial;
  bottom: -6em;
  top: initial;
}

.seven .circle {
  left: initial;
  top: initial;
  right: 1.5em;
  bottom: -2.1em;
}

.bio.seven::before,
.bio.seven::after {
  top: initial;
  bottom: -2.1em;
}

.bio.seven::before {
  width: calc(100% - 8em);
  border-radius: 0 0 0 1em;
}

.bio.seven::after {
  width: 1.5em;
  border-radius: 0 0 1em 0;
}

.seven .circle::after {
  top: initial;
  bottom: -7em;
}


/* Show how you can build further to use as a blockquote and hide the image text */

.eight footer .pic,
.seven footer .pic {
  overflow: hidden;
  text-indent: -999px;
}

.eight p:first-child {
  margin-top: 0;
}

.seven p:last-of-type {
  margin-bottom: 0;
}

blockquote.bio.seven {
  font-size: 100%;
}
              
            
!

JS

              
                
              
            
!
999px

Console