cssAudio - Activefile-genericCSS - ActiveGeneric - ActiveHTML - ActiveImage - ActiveJS - ActiveSVG - ActiveText - Activefile-genericVideo - Activehtmlicon-personicon-teamoctocatpop-outspinnerstartv

Pen Settings

CSS Base

Vendor Prefixing

Add External CSS

These stylesheets will be added in this order and before the code you write in the CSS editor. You can also add another Pen here, and it will pull the CSS from it. Try typing "font" or "ribbon" below.

Quick-add: + add another resource

Add External JavaScript

These scripts will run in this order and before the code in the JavaScript editor. You can also link to another Pen here, and it will run the JavaScript from it. Also try typing the name of any popular library.

Quick-add: + add another resource

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.

            
              <h1>Daily CSS Images :: 18 - Vampire <small>By Kim Doberstein</small></h1>


<div id="container"> 
  <div class="cssImageContainer" id="vampire">
    <div class="head">
      <div class="hair"></div>
      <div class="leftEye"><div class="brow"></div></div>
      <div class="rightEye"><div class="brow"></div></div>
      <div class="nose"></div>
      <div class="mouth"></div>
      <div class="leftTooth"></div>
      <div class="rightTooth"></div>
      <div class="blood"></div>
      
    </div>
    
    <div class="collar"></div>
    <div class="cape"></div>
    <div class="bow">
      <div class="rightBow"><div class="inner"></div></div>
      <div class="leftBow"><div class="inner"></div></div>
    </div>

  </div>
</div>

<div class="description">
  <h2>What  did I learn?</h2>
  <p>My arch mixin needed some work.</p>
  <p>Needed more time to add some gradients/shaddowing etc,but just ran out of time.</p>
  <p>My blood drop (aka teardrop) is just a simple triangle on top of a circle.  It would be nice to take some time and refine it into a nice mixin.</p>
</div>
            
          
!
            
              /****************** DESCRIPTION ****************/
h1{
  font-family: 'Pacifico', cursive;
  color:#333;
  font-size:5vw;
  small{
    display:block;
    margin-left:10%;
    color:#666;
  }
}

.description{
  font-family: 'Open Sans', sans-serif;
}
/************************************************/

#container{
  border:1px solid #000;
  position: relative;
  margin: auto;
  width: 75%;
}
/******************* VARS **********************/
$heightToWidthRatio:1.1; 
$bgColor:#47526d;
$faceColor:#dec5e2;
$bowColor:#b00;//#ff88aa;
/******************* MIXINS **********************/
@mixin square($widthSize, $heightToWidthRatio){
  /* for example 5/4 ratio would be 1.25 */
  height:calc(#{$widthSize}/#{$heightToWidthRatio});
  width:$widthSize;
}
@mixin circle($radiusWidth, $heightToWidthRatio){
  @include square($radiusWidth, $heightToWidthRatio);
  border-radius:50%;
}
@mixin size($widthPercent, $heightPercent){
  width:$widthPercent;
  height:$heightPercent;
}

@mixin position($left, $top){
  left:$left;
  top:$top;
}
@mixin sizePosition($widthPercent, $heightPercent,$left, $top){
  @include size($widthPercent, $heightPercent);
  @include position($left, $top);
}
@mixin arch($color, $bgColor, $heightToWidthRatio, $borderWidth, $position:top){
  overflow:hidden;
  
  &:before{
    width:100%;
    height:200%;
    background-color:$color;
    position:absolute;
    content:'';
    border-radius:50%;
    @if $position == 'top'{top:0}
    @else{bottom:0}
  }
  &:after{
    width:calc(100% - #{$borderWidth} * #{$heightToWidthRatio} *2);
    height:calc(((100% - #{$borderWidth}) * 2) );
    background-color:$bgColor;
    position:absolute;
    content:'';
    border-radius:50%;
    @if $position == 'top'{
      top:calc(#{$borderWidth} + 1px);
    }
    @else{
      bottom:calc(#{$borderWidth} + 1px);
    }
    
    left:calc(#{$borderWidth} * #{$heightToWidthRatio});
    
  }
}
@mixin triangle($color, $width,  $radius:30%, $position:relataive){
  
  
     position: $position;
	background-color: $color;
  
 &,&:before,&:after {
   width:  $width;
    height: $width;
    border-top-right-radius: $radius;
  }

  
  &:before,
  &:after {
    content: '';
    position: absolute;
    background-color: $color;
  }
  &{transform: rotate(-60deg) skewX(-30deg) scale(1,.866);}
  &:before { transform: rotate(-135deg) skewX(-45deg) scale(1.414,.707) translate(0,-50%);}
  &:after {transform: rotate(135deg) skewY(-45deg) scale(.707,1.414) translate(50%);}

}

/******************* MY IMAGE **********************/

#vampire{
  width: 100%;
  overflow:hidden;
  padding-bottom:calc(#{$heightToWidthRatio}*100%);
  position:relative;
  background-color:$bgColor;
  *, *:before, *:after{
    position:absolute;
    content:'';
    z-index:200;
  }
  
  .head{
    @include circle(75%,$heightToWidthRatio);
    background-color:$faceColor;
    left:12.5%;
    top:10%;
    overflow:hidden;
    
    .hair{
      background-color:#333;
      width:100%;
      height:30%;
      &:before, &:after{
         background-color:$faceColor;
        @include circle(55%,.3);
        
        top:50%;
      }
      &:before{left:1%}
      &:after{right:1%;}
    }
    
    .leftEye,.rightEye{
       @include circle(25%,1);
      background-color:#fff;
      top:30%;
      &:before{
         @include circle(60%,1);
        background-color:#d60202;
        left:30%;
        top:20%;
      }
      &:after{
        @include circle(50%,1);
        background-color:#000;
        left:38%;
        top:20%;
      }
      
      .brow{
        width:120%;
        height:45%;
        top:-5%;
        left:-10%;
        background-color:$faceColor;
        z-index:300
      }
    }
    .leftEye{left:18%; .brow{transform:rotate(15deg)}}
    .rightEye{right:18%; .brow{transform:rotate(-15deg)}}
    
    .nose{
      @include arch(#333, $faceColor, 1, 5%, bottom);
      width:10%;
      height:5%;
      left:45%;
      top:60%;
      
      
    }
    
    .mouth{
      //background-color:#333;
      @include arch(#333, $faceColor, 1, 2%);
      width:50%;
      height:5%;
      top:70%;
      left:25%;
    }
    .leftTooth, .rightTooth{
      background-color: #fff;
      clip-path: polygon(0% 0%, 100% 0%, 50% 100%);
      width:8%;
      height:10%;
      top:71%;
    }
    .leftTooth{left:35%;transform:rotate(-5deg)}
    .rightTooth{right:35%;transform:rotate(5deg)}
    .blood{
      background-color:#f00;
      @include circle(4%,1);
      left:60%;
      top:80%;
      
      &:after{
        width:90%;
        height:50%;
        left:5%;
        clip-path: polygon(50% 0%, 0% 100%, 100% 100%);
        background-color:#f00;
        top:-25%;
      }
    }
  }
  
  .collar{
   
      background-color:#000;
      clip-path: polygon(0% 0%, 25% 100%, 75% 100%, 100% 0%);
      height:40%;
      width:100%;
    top:65%;
    z-index:100;
  
  }
  .cape{
    background-color:#fff;
     border-radius:25% 25% 0 0 / 100% 100% 0 0 ;
    width:60%;
    height:30%;
    bottom:0;
    left:20%;
    z-index:150
  }
  .bow{
    height:30%;
    width:30%;
    background:none;
   // border:1px solid #f00;
    //transform:rotate(40deg);
    left:40%;
    top:76%;
    .rightBow,.leftBow{
        background:none;
       @include square(30%, $heightToWidthRatio);
      
      .inner{
        @include triangle($bowColor, 100%,  $radius:50%, $position:relataive);
      }
    }
    .rightBow{
      transform:rotate(-90deg);
      left:35%;
    }
    .leftBow{
      transform:rotate(90deg);
    }
    &:after{
      background-color:$bowColor;
      @include circle(20%,1);
      left:25%;
      top:2%;
    }
  }
}

            
          
!
999px
Close

Asset uploading is a PRO feature.

As a PRO member, you can drag-and-drop upload files here to use as resources. Images, Libraries, JSON data... anything you want. You can even edit them anytime, like any other code on CodePen.

Go PRO

Loading ..................

Console