css Audio - Active file-generic CSS - Active Generic - Active HTML - Active JS - Active SVG - Active Text - Active file-generic Video - Active header Love html icon-new-collection icon-person icon-team numbered-list123 pop-out spinner split-screen star tv

Pen Settings

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URL's added here will be added as <link>s in order, and before the CSS in the editor. If you link to another Pen, it will include the CSS from that Pen. If the preprocessor matches, it will attempt to combine them before processing.

+ add another resource

You're using npm packages, so we've auto-selected Babel for you here, which we require to process imports and make it all work. If you need to use a different JavaScript preprocessor, remove the packages in the npm tab.

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

Use npm Packages

We can make npm packages available for you to use in your JavaScript. We use webpack to prepare them and make them available to import. We'll also process your JavaScript with Babel.

⚠️ This feature can only be used by logged in users.

Code Indentation

     

Save Automatically?

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.

HTML Settings

Here you can Sed posuere consectetur est at lobortis. Donec ullamcorper nulla non metus auctor fringilla. Maecenas sed diam eget risus varius blandit sit amet non magna. Donec id elit non mi porta gravida at eget metus. Praesent commodo cursus magna, vel scelerisque nisl consectetur et.

            
              <link href='https://fonts.googleapis.com/css?family=Raleway:400,300' rel='stylesheet' type='text/css'>
<div class="container clearfix">
   <div class="avatar">
     <input id="fileUpload" type="file" />
      <svg version="1.1" id="camera" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
         viewBox="0 0 25 15" enable-background="new 0 0 25 15" xml:space="preserve">
      <path id="cameraFrame" fill="none" stroke="white" stroke-miterlimit="10" d="M23.1,14.1H1.9c-0.6,0-1-0.4-1-1V1.9c0-0.6,0.4-1,1-1h21.2
         c0.6,0,1,0.4,1,1v11.3C24.1,13.7,23.7,14.1,23.1,14.1z"/>
      <path id="circle" fill="none" stroke="#ffffff" stroke-width="1.4" stroke-miterlimit="12" d="M17.7,7.5c0-2.8-2.3-5.2-5.2-5.2S7.3,4.7,7.3,7.5s2.3,5.2,5.2,5.2
         S17.7,10.3,17.7,7.5z"/>
      <g id="plus">
         <path fill="none" id="plusLine" class="line" stroke="#ffffff" stroke-linecap="round" stroke-miterlimit="10" d="M20.9,2.3v4.4"/>
         <path fill="none" class="line"stroke="#ffffff" stroke-linecap="round" stroke-miterlimit="10" d="M18.7,4.6h4.4"/>
      </g>
     </svg>
     <div id="openModal">
       <span>Drop here or</span>
     </div>
      </div
   </div>
        <div class="right">
          <p>Mike</p>
          <p>Miller</p>
          <p>France</p>
        </div>
</div>
<p class="src">Photo source: Shutterstock<p>
            
          
!
            
              $blue: #2B2F3F
$pinkish: #C68587
$reddish: #BA4773

html 
  background-image: url(https://s3-us-west-2.amazonaws.com/s.cdpn.io/176026/noise.png)
  background-color: #fff
  
.avatar
  float: left
  display: inline-block
  overflow: hidden
  width: 10vw
  height: 10vw
  border-radius: 100%
  background: $pinkish
  border: 6px solid #B3C9CB
  background-image: url(https://scontent-vie1-1.cdninstagram.com/hphotos-ash/t51.2885-19/10932224_821299211264682_1488190390_a.jpg)
  background-size: cover
  background-position: 50% 25%
  -webkit-transition: border 0.5s linear
  -moz-transition: border 0.5s linear
  -o-transition: border 0.5s linear
  transition: border 0.5s linear
    
  &:after
    content: ""
    position: absolute
    background: -webkit-gradient(linear, left top, right bottom, color-stop(0%,rgba(240,227,199,1)), color-stop(100%,rgba(107,202,180,1)))
    width: 10vw
    height: 10vw
    border-radius: 100%
    border: 1px solid white
    left: 4px
    top: 4px
    opacity: 0
    -webkit-transition: opacity 0.3s linear
    -moz-transition: opacity 0.3s linear
    -o-transition: opacity 0.3s linear
    transition: opacity 0.3s linear
    cursor: pointer
    -webkit-transform-style: preserve-3d
      
.avatar:hover:after
  opacity: 0.7
.avatar.open:hover:after
  opacity: 0
.container
  text-align: center
  left: 50%
  -webkit-transform: translate3d(-50%,-50%,0)
  -moz-transition: translate3d(-50%,-50%,0)
  -o-transition: translate3d(-50%,-50%,0)
  transition: translate3d(-50%,-50%,0)
  position: absolute
  top: 50%
#camera
  -webkit-transform: scale(0.4)
  position: relative
  z-index: 9999
  cursor: pointer
  top: 18%
  overflow: hidden

#circle
  -webkit-transform: scale(0.75)
  -webkit-transform-origin: 50% 50%
  -webkit-transition: all 0.3s linear
  stroke-dashoffset: 33px
  stroke-dasharray: 33px
#cameraFrame
  -webkit-transition: all 0.5s linear
  stroke-dashoffset: 72px
  stroke-dasharray: 72px
#plus
  -webkit-transition: all 0.3s linear
  stroke-dashoffset: 5px
  stroke-dasharray: 5px
  
#fileUpload
  overflow: hidden
  position: absolute
  width: 70px
  padding: 10px
  opacity: 0
  left: 50%
  top: 70%
  -webkit-transform: translate3d(-50%,-50%,0)
  z-index: 9999
  -webkit-transition: 250ms cubic-bezier(.7,0,.36,1)
  transition: 250ms cubic-bezier(.7,0,.36,1)
  &:focus
    outline: none
    background: transparent
#openModal   
  width: 100%
  height: 100%
  position: absolute
  left: 0
  top: 0
  border-radius: 100%
  -webkit-transform: scale(0)
  z-index: 8888
  -webkit-transition: 250ms cubic-bezier(.7,0,.36,1)
  transition: 250ms cubic-bezier(.7,0,.36,1)
  -webkit-transition-delay: 250ms
  transition-delay: 250ms
  background-color: rgba(255,255,255,0.9)
  
#openModal
  > span
    font-family: raleway
    font-size: 1.2vw
    top: 40%
    position: absolute
    left: 50%
    white-space: nowrap
    -webkit-transform: translate3d(-50%,0,0)
    color: rgba(0,0,0,0.7)
.separatorLine
  margin-top: 15px
  width: 300%
  position: absolute
  height: 1px
  background: rgba(0,0,0,0.6)
.clearfix:after 
  clear: both
  content: "."
  display: block
  height: 0
  visibility: hidden

.clearfix 
  display: inline-block

.clearfix 
  display: block
.right
  margin-left: 12.5vw
  bottom: 0
  position: absolute
  float: right
.right > p
  font-size: 2vw
  text-align: left
  text-transform: none
  font-family: Raleway
  margin-top: 0.5vw
  color: rgba(0,0,0,0.7)
  &:last-child
    margin-top: 0.2vw
    font-size: 0.9vw
    text-align: right
    color: rgba(0,0,0,0.5)
       
.avatar:hover
  > #camera 
    > #cameraFrame
      stroke-dashoffset: 0
.avatar:hover
  > #camera 
    > #circle
      stroke-dashoffset: 0px
.avatar:hover
  > #camera 
    > #plus
      stroke-dashoffset: 0px
      
.avatar:active
  > #camera
    > #cameraFrame
      -webkit-transition: none
      stroke: rgba(255,255,255,0.7)

.avatar:active
  > #camera
    > #circle
      -webkit-transition: none
      stroke: rgba(255,255,255,0.7)

.avatar:active
  > #camera
    > #plus
      -webkit-transition: none
      stroke: rgba(255,255,255,0)
.src
  font-family: raleway
  position: absolute
  display: inline-block
  right: 0
  bottom: 0
  padding: 10px
#camera
  -webkit-transition: 250ms cubic-bezier(.7,0,.36,1)
  transition: 250ms cubic-bezier(.7,0,.36,1)
.avatar.open
  > #camera
    -webkit-transform: scale(0)
    fill: white
.avatar.open
  > #openModal
    -webkit-transform: scale(0.95)
.avatar.open
  > #fileUpload
    opacity: 1
    -webkit-transition-delay: 250ms
.avatar.open
  > #camera
    visibility: hidden
            
          
!
            
              /*

*************
30.10 ~ included vendor prefixes
28.10 ~ added code that closed the upload frame if we click outside of our avatar.

This is the jQuery solution to our animation. Out of performance reasons I would always advise the usage of CSS animations or some other GPU accelerated animations with the  use of TweenJS, GSAP or VelocityJS.

I hope you like the animation, thanks! :)

*************

var circle = $('#circle').get(0);
var cl = circle.getTotalLength();

var frame = $('#cameraFrame').get(0);
var fl = frame.getTotalLength();

var plusG = $('#plus')
var plusLine = $('#plusLine').get(0).getTotalLength();
$(plusG).css({
  'stroke-dasharray':plusLine,
  'stroke-dashoffset':plusLine
});
$(circle).css({
  'stroke-dasharray':cl,
  'stroke-dashoffset':cl
});
console.log(plusLine)
$(frame).css({
  'stroke-dasharray':fl,
  'stroke-dashoffset':fl-fl
});
/*
$('.avatar').hover(
  function(){
    $(circle).css({
      'stroke-dashoffset':0
    });
    $(frame).css({
      'stroke-dashoffset':0
    });
    $(plusG).css({
      'stroke-dashoffset':0
    });
},function(){
   $(circle).css({
      'stroke-dashoffset':cl});
    $(frame).css({
      'stroke-dashoffset':fl
    });
  $(plusG).css({
      'stroke-dashoffset':plusLine
    });
});*/
$('#fileUpload').on('change',function(){
  $('.avatar').removeClass('open');
});
$('.avatar').on('click',function(){
  $(this).addClass('open');
});
// added code to close the modal if you click outside
$('html').click(function() {
 $('.avatar').removeClass('open');
});

$('.avatar').click(function(event){
    event.stopPropagation();
});


            
          
!
999px
🕑 One or more of the npm packages you are using needs to be built. You're the first person to ever need it! We're building it right now and your preview will start updating again when it's ready.
Loading ..................

Console