2016-05-24 16 views
3

Ich möchte Circle Hover Effects mit CSS-Übergängen auf <img> Tag ohne Aufruf des Bildes als Hintergrundbild.Wie bekomme ich Circle Hover-Effekte mit CSS-Übergängen mit dem img-Tag?

Ich habe eine JSFiddle des gewünschten Effekts erstellt. Aber in dieser Geige wird das Bild als Hintergrundbild verwendet. Ich möchte den gleichen Effekt, aber mit Bild in einem img Tag, nicht als Hintergrundbild.

.ch-item { 
 
    width: 100%; 
 
    height: 100%; 
 
    border-radius: 50%; 
 
    position: relative; 
 
    cursor: default; 
 
    box-shadow: inset 0 0 0 0 rgba(200, 95, 66, 0.4), inset 0 0 0 16px rgba(255, 255, 255, 0.6), 0 1px 2px rgba(0, 0, 0, 0.1); 
 
    -webkit-transition: all 0.4s ease-in-out; 
 
    -moz-transition: all 0.4s ease-in-out; 
 
    -o-transition: all 0.4s ease-in-out; 
 
    -ms-transition: all 0.4s ease-in-out; 
 
    transition: all 0.4s ease-in-out; 
 
} 
 
.ch-img-1 { 
 
    background-image: url(http://tympanus.net/Tutorials/CircleHoverEffects/images/5.jpg); 
 
} 
 
.ch-img-2 { 
 
    background-image: url(http://tympanus.net/Tutorials/CircleHoverEffects/images/5.jpg); 
 
} 
 
.ch-img-3 { 
 
    background-image: url(http://tympanus.net/Tutorials/CircleHoverEffects/images/5.jpg); 
 
} 
 
.ch-info { 
 
    position: absolute; 
 
    width: 100%; 
 
    height: 100%; 
 
    border-radius: 50%; 
 
    opacity: 0; 
 
    -webkit-transition: all 0.4s ease-in-out; 
 
    -moz-transition: all 0.4s ease-in-out; 
 
    -o-transition: all 0.4s ease-in-out; 
 
    -ms-transition: all 0.4s ease-in-out; 
 
    transition: all 0.4s ease-in-out; 
 
    -webkit-transform: scale(0); 
 
    -moz-transform: scale(0); 
 
    -o-transform: scale(0); 
 
    -ms-transform: scale(0); 
 
    transform: scale(0); 
 
    -webkit-backface-visibility: hidden; 
 
} 
 
.ch-info h3 { 
 
    color: #fff; 
 
    text-transform: uppercase; 
 
    position: relative; 
 
    letter-spacing: 2px; 
 
    font-size: 22px; 
 
    margin: 0 30px; 
 
    padding: 65px 0 0 0; 
 
    height: 110px; 
 
    font-family: 'Open Sans', Arial, sans-serif; 
 
    text-shadow: 0 0 1px #fff, 0 1px 2px rgba(0, 0, 0, 0.3); 
 
} 
 
.ch-info p { 
 
    color: #fff; 
 
    padding: 10px 5px; 
 
    font-style: italic; 
 
    margin: 0 30px; 
 
    font-size: 12px; 
 
    border-top: 1px solid rgba(255, 255, 255, 0.5); 
 
} 
 
.ch-info p a { 
 
    display: block; 
 
    color: #fff; 
 
    color: rgba(255, 255, 255, 0.7); 
 
    font-style: normal; 
 
    font-weight: 700; 
 
    text-transform: uppercase; 
 
    font-size: 9px; 
 
    letter-spacing: 1px; 
 
    padding-top: 4px; 
 
    font-family: 'Open Sans', Arial, sans-serif; 
 
} 
 
.ch-info p a:hover { 
 
    color: #fff222; 
 
    color: rgba(255, 242, 34, 0.8); 
 
} 
 
.ch-item:hover { 
 
    box-shadow: inset 0 0 0 110px rgba(200, 95, 66, 0.4), inset 0 0 0 16px rgba(255, 255, 255, 0.8), 0 1px 2px rgba(0, 0, 0, 0.1); 
 
} 
 
.ch-item:hover .ch-info { 
 
    opacity: 1; 
 
    -webkit-transform: scale(1); 
 
    -moz-transform: scale(1); 
 
    -o-transform: scale(1); 
 
    -ms-transform: scale(1); 
 
    transform: scale(1); 
 
} 
 
@import url('normalize.css'); 
 

 
/* General Demo Style */ 
 

 
body { 
 
    font-family: Cambria, Georgia, serif; 
 
    background: #f9f9f9 url(../images/bg.jpg); 
 
    font-weight: 300; 
 
    font-size: 15px; 
 
    color: #333; 
 
    -webkit-font-smoothing: antialiased; 
 
    overflow-y: scroll; 
 
    overflow-x: hidden; 
 
} 
 
a { 
 
    color: #555; 
 
    text-decoration: none; 
 
} 
 
.container { 
 
    width: 100%; 
 
    position: relative; 
 
} 
 
.clr { 
 
    clear: both; 
 
    padding: 0; 
 
    height: 0; 
 
    margin: 0; 
 
} 
 
.main { 
 
    width: 90%; 
 
    margin: 0 auto; 
 
    position: relative; 
 
} 
 
.container > header { 
 
    margin: 10px; 
 
    padding: 20px 10px 10px 10px; 
 
    position: relative; 
 
    display: block; 
 
    text-shadow: 1px 1px 1px rgba(0, 0, 0, 0.2); 
 
    text-align: center; 
 
} 
 
.container > header h1 { 
 
    font-size: 32px; 
 
    line-height: 32px; 
 
    margin: 0; 
 
    position: relative; 
 
    font-weight: 300; 
 
    color: #777; 
 
    text-shadow: 1px 1px 1px rgba(255, 255, 255, 0.7); 
 
} 
 
.container > header h2 { 
 
    font-size: 14px; 
 
    font-weight: 300; 
 
    font-style: italic; 
 
    margin: 0; 
 
    padding: 15px 0 5px 0; 
 
    color: #888; 
 
    text-shadow: 1px 1px 1px rgba(255, 255, 255, 0.9); 
 
} 
 
/* Header Style */ 
 

 
.codrops-top { 
 
    line-height: 24px; 
 
    font-size: 11px; 
 
    background: #fff; 
 
    background: rgba(255, 255, 255, 0.6); 
 
    text-transform: uppercase; 
 
    z-index: 9999; 
 
    position: relative; 
 
    box-shadow: 1px 0px 2px rgba(0, 0, 0, 0.1); 
 
} 
 
.codrops-top a { 
 
    padding: 0px 10px; 
 
    letter-spacing: 1px; 
 
    color: #333; 
 
    display: inline-block; 
 
} 
 
.codrops-top a:hover { 
 
    background: rgba(255, 255, 255, 0.3); 
 
} 
 
.codrops-top span.right { 
 
    float: right; 
 
} 
 
.codrops-top span.right a { 
 
    float: left; 
 
    display: block; 
 
} 
 
/* Demo Buttons Style */ 
 

 
.codrops-demos { 
 
    text-align: center; 
 
    display: block; 
 
    line-height: 30px; 
 
    padding: 5px 0px; 
 
} 
 
.codrops-demos a { 
 
    display: inline-block; 
 
    font-style: italic; 
 
    margin: 0px 4px; 
 
    padding: 0px 6px; 
 
    color: #aaa; 
 
    line-height: 20px; 
 
    font-size: 13px; 
 
    text-shadow: 1px 1px 1px #fff; 
 
    border: 1px solid #fff; 
 
    background: #ffffff; 
 
    /* Old browsers */ 
 
    background: -moz-linear-gradient(top, #ffffff 0%, #f6f6f6 47%, #ededed 100%); 
 
    /* FF3.6+ */ 
 
    background: -webkit-gradient(linear, left top, left bottom, color-stop(0%, #ffffff), color-stop(47%, #f6f6f6), color-stop(100%, #ededed)); 
 
    /* Chrome,Safari4+ */ 
 
    background: -webkit-linear-gradient(top, #ffffff 0%, #f6f6f6 47%, #ededed 100%); 
 
    /* Chrome10+,Safari5.1+ */ 
 
    background: -o-linear-gradient(top, #ffffff 0%, #f6f6f6 47%, #ededed 100%); 
 
    /* Opera 11.10+ */ 
 
    background: -ms-linear-gradient(top, #ffffff 0%, #f6f6f6 47%, #ededed 100%); 
 
    /* IE10+ */ 
 
    background: linear-gradient(top, #ffffff 0%, #f6f6f6 47%, #ededed 100%); 
 
    /* W3C */ 
 
    filter: progid: DXImageTransform.Microsoft.gradient(startColorstr='#ffffff', endColorstr='#ededed', GradientType=0); 
 
    /* IE6-9 */ 
 
    box-shadow: 0 1px 1px rgba(0, 0, 0, 0.1); 
 
} 
 
.codrops-demos a:hover { 
 
    color: #333; 
 
    background: #fff; 
 
} 
 
.codrops-demos a:active { 
 
    background: #fff; 
 
} 
 
.codrops-demos a.current-demo, 
 
.codrops-demos a.current-demo:hover { 
 
    background: #f0f0f0; 
 
    border-color: #d9d9d9; 
 
    color: #aaa; 
 
    box-shadow: 0 1px 1px rgba(255, 255, 255, 0.7); 
 
    filter: progid: DXImageTransform.Microsoft.gradient(startColorstr='#f6f6f6', endColorstr='#f6f6f6', GradientType=0); 
 
    /* IE6-9 */ 
 
} 
 
.support-note span { 
 
    color: #ac375d; 
 
    font-size: 16px; 
 
    display: none; 
 
    font-weight: bold; 
 
    text-align: center; 
 
    padding: 5px 0; 
 
} 
 
.no-cssanimations .support-note span.no-cssanimations, 
 
.no-csstransforms .support-note span.no-csstransforms, 
 
.no-csstransforms3d .support-note span.no-csstransforms3d, 
 
.no-csstransitions .support-note span.no-csstransitions { 
 
    display: block; 
 
} 
 
.ch-grid { 
 
    margin: 20px 0 0 0; 
 
    padding: 0; 
 
    list-style: none; 
 
    display: block; 
 
    text-align: center; 
 
    width: 100%; 
 
} 
 
.ch-grid:after, 
 
.ch-item:before { 
 
    content: ''; 
 
    display: table; 
 
} 
 
.ch-grid:after { 
 
    clear: both; 
 
} 
 
.ch-grid li { 
 
    width: 220px; 
 
    height: 220px; 
 
    display: inline-block; 
 
    margin: 20px; 
 
}
<section class="main"> 
 

 
    <ul class="ch-grid"> 
 
    <li> 
 
     <div class="ch-item ch-img-1"> 
 
     <div class="ch-info"> 
 
      <h3>Brainiac</h3> 
 
      <p>by Daniel Nyari <a href="http://drbl.in/eODP">View on Dribbble</a> 
 
      </p> 
 
     </div> 
 
     </div> 
 
    </li> 
 
    <li> 
 
     <div class="ch-item ch-img-2"> 
 
     <div class="ch-info"> 
 
      <h3>Vision</h3> 
 
      <p>by Daniel Nyari <a href="http://drbl.in/eNXW">View on Dribbble</a> 
 
      </p> 
 
     </div> 
 
     </div> 
 
    </li> 
 
    <li> 
 
     <div class="ch-item ch-img-3"> 
 
     <div class="ch-info"> 
 
      <h3>Cylon</h3> 
 
      <p>by Daniel Nyari <a href="http://drbl.in/eNXY">View on Dribbble</a> 
 
      </p> 
 
     </div> 
 
     </div> 
 
    </li> 
 
    </ul> 
 

 
</section>

+1

Code hinzufügen und was Sie versucht so weit , oh Gott, ich will so viele Dinge zu haben;) –

+0

Können Sie die Frage umformulieren, es ist zu schwer zu verstehen !! – Pugazh

+0

kannst du es jetzt verstehen ??? :) bitte hilfe –

Antwort

1

ich Ihre Geige hier bearbeitet haben: http://jsfiddle.net/pedwf80h/7/

Wesentlichen die img URL aus dem Hintergrund im li Element bewegt ich habe. Dann positionierte das img absolut und benutzte z-index um es nach hinten zu verschieben. Das Element li verwendet dann overflow: hidden und border-radius: 100%, um das Bild, das sich außerhalb unseres li-Elements befindet, auszublenden.

Hoffe, das hilft!

1

Versuchen Sie, diese kann dies für Sie Hilfe sein kann:

.ch-item { 
 
    width: 100%; 
 
    height: 100%; 
 
    border-radius: 50%; 
 
    position: relative; 
 
    cursor: default; 
 
    box-shadow: inset 0 0 0 0 rgba(200, 95, 66, 0.4), inset 0 0 0 16px rgba(255, 255, 255, 0.6), 0 1px 2px rgba(0, 0, 0, 0.1); 
 
    -webkit-transition: all 0.4s ease-in-out; 
 
    -moz-transition: all 0.4s ease-in-out; 
 
    -o-transition: all 0.4s ease-in-out; 
 
    -ms-transition: all 0.4s ease-in-out; 
 
    transition: all 0.4s ease-in-out; 
 
    z-index: 2; 
 
} 
 
.ch-info { 
 
    position: absolute; 
 
    width: 100%; 
 
    height: 100%; 
 
    border-radius: 50%; 
 
    opacity: 0; 
 
    -webkit-transition: all 0.4s ease-in-out; 
 
    -moz-transition: all 0.4s ease-in-out; 
 
    -o-transition: all 0.4s ease-in-out; 
 
    -ms-transition: all 0.4s ease-in-out; 
 
    transition: all 0.4s ease-in-out; 
 
    -webkit-transform: scale(0); 
 
    -moz-transform: scale(0); 
 
    -o-transform: scale(0); 
 
    -ms-transform: scale(0); 
 
    transform: scale(0); 
 
    -webkit-backface-visibility: hidden; 
 
} 
 

 
li { 
 
    position: relative; 
 
    overflow: hidden; 
 
    border-radius: 100%; 
 
} 
 

 
li img { 
 
    position: absolute; 
 
    top: 0; 
 
    left: 0; 
 
    z-index: 1; 
 
} 
 

 

 
.ch-item:hover { 
 
    box-shadow: inset 0 0 0 110px rgba(200, 95, 66, 0.4), inset 0 0 0 16px rgba(255, 255, 255, 0.8), 0 1px 2px rgba(0, 0, 0, 0.1); 
 
} 
 

 
.ch-item:hover .ch-info { 
 
    opacity: 1; 
 
    -webkit-transform: scale(1); 
 
    -moz-transform: scale(1); 
 
    -o-transform: scale(1); 
 
    -ms-transform: scale(1); 
 
    transform: scale(1); 
 
} 
 
@import url('normalize.css'); 
 

 
/* General Demo Style */ 
 
body{ 
 
\t font-family: Cambria, Georgia, serif; 
 
\t background: #f9f9f9 url(../images/bg.jpg); 
 
\t font-weight: 300; 
 
\t font-size: 15px; 
 
\t color: #333; 
 
\t -webkit-font-smoothing: antialiased; 
 
\t overflow-y: scroll; 
 
\t overflow-x: hidden; 
 
} 
 
a{ 
 
\t color: #555; 
 
\t text-decoration: none; 
 
} 
 
.container{ 
 
\t width: 100%; 
 
\t position: relative; 
 
} 
 
.clr{ 
 
\t clear: both; 
 
\t padding: 0; 
 
\t height: 0; 
 
\t margin: 0; 
 
} 
 
.main{ 
 
\t width: 90%; 
 
\t margin: 0 auto; 
 
\t position: relative; 
 
} 
 
.container > header{ 
 
\t margin: 10px; 
 
\t padding: 20px 10px 10px 10px; 
 
\t position: relative; 
 
\t display: block; 
 
\t text-shadow: 1px 1px 1px rgba(0,0,0,0.2); 
 
    text-align: center; 
 
} 
 
.container > header h1{ 
 
\t font-size: 32px; 
 
\t line-height: 32px; 
 
\t margin: 0; 
 
\t position: relative; 
 
\t font-weight: 300; 
 
\t color: #777; 
 
\t text-shadow: 1px 1px 1px rgba(255,255,255,0.7); 
 
} 
 
.container > header h2{ 
 
\t font-size: 14px; 
 
\t font-weight: 300; 
 
\t font-style: italic; 
 
\t margin: 0; 
 
\t padding: 15px 0 5px 0; 
 
\t color: #888; 
 
\t text-shadow: 1px 1px 1px rgba(255,255,255,0.9); 
 
} 
 
/* Header Style */ 
 
.codrops-top{ 
 
\t line-height: 24px; 
 
\t font-size: 11px; 
 
\t background: #fff; 
 
\t background: rgba(255, 255, 255, 0.6); 
 
\t text-transform: uppercase; 
 
\t z-index: 9999; 
 
\t position: relative; 
 
\t box-shadow: 1px 0px 2px rgba(0,0,0,0.1); 
 
} 
 
.codrops-top a{ 
 
\t padding: 0px 10px; 
 
\t letter-spacing: 1px; 
 
\t color: #333; 
 
\t display: inline-block; 
 
} 
 
.codrops-top a:hover{ 
 
\t background: rgba(255,255,255,0.3); 
 
} 
 
.codrops-top span.right{ 
 
\t float: right; 
 
} 
 
.codrops-top span.right a{ 
 
\t float: left; 
 
\t display: block; 
 
} 
 
/* Demo Buttons Style */ 
 
.codrops-demos{ 
 
    text-align:center; 
 
\t display: block; 
 
\t line-height: 30px; 
 
\t padding: 5px 0px; 
 
} 
 
.codrops-demos a{ 
 
    display: inline-block; 
 
\t font-style: italic; 
 
\t margin: 0px 4px; 
 
\t padding: 0px 6px; 
 
\t color: #aaa; 
 
\t line-height: 20px; \t 
 
\t font-size: 13px; 
 
\t text-shadow: 1px 1px 1px #fff; 
 
\t border: 1px solid #fff; 
 
\t background: #ffffff; /* Old browsers */ 
 
\t background: -moz-linear-gradient(top, #ffffff 0%, #f6f6f6 47%, #ededed 100%); /* FF3.6+ */ 
 
\t background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#ffffff), color-stop(47%,#f6f6f6), color-stop(100%,#ededed)); /* Chrome,Safari4+ */ 
 
\t background: -webkit-linear-gradient(top, #ffffff 0%,#f6f6f6 47%,#ededed 100%); /* Chrome10+,Safari5.1+ */ 
 
\t background: -o-linear-gradient(top, #ffffff 0%,#f6f6f6 47%,#ededed 100%); /* Opera 11.10+ */ 
 
\t background: -ms-linear-gradient(top, #ffffff 0%,#f6f6f6 47%,#ededed 100%); /* IE10+ */ 
 
\t background: linear-gradient(top, #ffffff 0%,#f6f6f6 47%,#ededed 100%); /* W3C */ 
 
\t filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#ffffff', endColorstr='#ededed',GradientType=0); /* IE6-9 */ 
 
\t box-shadow: 0 1px 1px rgba(0, 0, 0, 0.1); 
 
} 
 
.codrops-demos a:hover{ 
 
\t color: #333; 
 
\t background: #fff; 
 
} 
 
.codrops-demos a:active{ 
 
\t background: #fff; 
 
} 
 
.codrops-demos a.current-demo, 
 
.codrops-demos a.current-demo:hover{ 
 
\t background: #f0f0f0; 
 
\t border-color: #d9d9d9; 
 
\t color: #aaa; 
 
\t box-shadow: 0 1px 1px rgba(255,255,255,0.7); 
 
\t filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#f6f6f6', endColorstr='#f6f6f6',GradientType=0); /* IE6-9 */ 
 
} 
 

 
.support-note span{ 
 
\t color: #ac375d; 
 
\t font-size: 16px; 
 
\t display: none; 
 
\t font-weight: bold; 
 
\t text-align: center; 
 
\t padding: 5px 0; 
 
} 
 
.no-cssanimations .support-note span.no-cssanimations, 
 
.no-csstransforms .support-note span.no-csstransforms, 
 
.no-csstransforms3d .support-note span.no-csstransforms3d, 
 
.no-csstransitions .support-note span.no-csstransitions{ 
 
\t display: block; 
 
} 
 
.ch-grid { 
 
\t margin: 20px 0 0 0; 
 
\t padding: 0; 
 
\t list-style: none; 
 
\t display: block; 
 
\t text-align: center; 
 
\t width: 100%; 
 
} 
 

 
.ch-grid:after, 
 
.ch-item:before { 
 
\t content: ''; 
 
    display: table; 
 
} 
 

 
.ch-grid:after { 
 
\t clear: both; 
 
} 
 

 
.ch-grid li { 
 
\t width: 220px; 
 
\t height: 220px; 
 
\t display: inline-block; 
 
\t margin: 20px; 
 
}
<section class="main"> 
 

 
    <ul class="ch-grid"> 
 
    <li> 
 
     <img src="http://tympanus.net/Tutorials/CircleHoverEffects/images/5.jpg" alt="Vision"> 
 
     <div class="ch-item"> 
 
     <div class="ch-info"> 
 
    
 
     </div> 
 
     </div> 
 
    </li> 
 
    </ul> 
 

 
</section>

1

Weitere Referenz-Website ... Reference link

@import url(http://fonts.googleapis.com/css?family=Cabin:700); 

body { 
    padding-top: 2em; 
    background-color: #c02227; 
} 

.circle-container { 
    position: relative; 
    perspective: 1000; 
    margin: 0 auto; 
} 

.circle-container:hover .circle { 
    transform: rotate3d(45, 45, 0, 180deg); 
} 

.circle-container:hover .outer-ring { 
    transform: rotate3d(45, 0, 0, 180deg); 
} 

.circle-container:hover .outer-outer-ring { 
    transform: rotate3d(0, 45, 0, 180deg); 
} 

.circle-container, .front, .back { 
    width: 175px; 
    height: 175px; 
    background-color: rgba(0,0,0,0); 
} 

.circle, .outer-ring, .outer-outer-ring { 
    transition: 0.5s; 
    transform-style: preserve-3d; 
    transition-timing-function: cubic-bezier(0.785, 0.135, 0.150, 0.860); 
} 

.circle { 
    position: relative; 
    width: 175px; 
    height: 175px; 
} 

.front, .back { 
    border-radius: 50%; 
    box-shadow: 0px 0px 20px rgba(0,0,0,0.4); 
    backface-visibility: hidden; 
    position: absolute; 
    top: 0; 
    left: 0; 
} 

.front { 
    background-color: #fff; 
    z-index: 2; 
} 

.front p { 
    margin-top: 1.2em; 
    font-family: cabin, sans-serif; 
    font-weight: 700; 
    font-size: 3em; 
    text-align: center; 
    color: #c02227; 
} 

.back { 
    transform: rotate3d(45,45,0,180deg); 
    background-color: #fff; 
} 

.back-logo { 
    width: 60%; 
    display: block; 
    margin: 2em auto; 
} 

.outer-ring { 
    position: absolute; 
    top: -10px; 
    left: -10px; 
    border-radius: 50%; 
    border: 2px solid #fff; 
    width: 191px; 
    height: 191px; 
    background-color: rgba(255,255,255,0); 
    box-shadow: 0px 0px 20px rgba(0,0,0,0.4); 
} 

.outer-outer-ring { 
    position: absolute; 
    top: -20px; 
    left: -20px; 
    border-radius: 50%; 
    border: 2px solid #fff; 
    width: 211px; 
    height: 211px; 
    background-color: rgba(255,255,255,0); 
    box-shadow: 0px 0px 20px rgba(0,0,0,0.4); 
}