4
sign up log in tour help stack overflow careers Take the 2minute tour × Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required. Creating a Zoom Effect on an image on hover using CSS? I'm currently trying to create a zoom effect on hover over one of my four images. The problem is most examples usually use tables or mask divs to apply some sort of effect. Here's one example that implements what I would like . this is my code so far. This Thanks so much!! HTML <div id="menu"> <img class ="blog" src="http://s18.postimg.org/il7hbk7i1/image.png" alt=""> <img class ="music" src="http://s18.postimg.org/4st2fxgqh/image.png" alt=""> <img class ="projects" src="http://s18.postimg.org/sxtrxn115/image.png" alt=""> <img class ="bio" src="http://s18.postimg.org/5xn4lb37d/image.png" alt=""> </div> CSS #menu { max‐width: 1200px; text‐align: center; margin: auto; } #menu img { width: 250px; height: 375px; padding: 0px 5px 0px 5px; overflow: hidden; } .blog { height: 375px; ‐webkit‐transition: all 1s ease; ‐moz‐transition: all 1s ease; ‐o‐transition: all 1s ease; ‐ms‐transition: all 1s ease; transition: all 1s ease; } .blog:hover { cursor: pointer; height:475px; width: 350px; } .music { height: 375px; } .projects { height: 375px; } .bio { height: 375px; } css html5 class css3 edited Dec 26 '13 at 5:29 neshpro9 394 2 15 asked Apr 2 '13 at 5:49 KingPolygon 1,043 4 11 34 vote up for the link you posted, it helped me :) neshpro9 Dec 26 '13 at 6:16 4 Answers

html5 - Creating a Zoom Effect on an image on hover using CSS_ - Stack Overflow.pdf

  • Upload
    safsdf

  • View
    217

  • Download
    0

Embed Size (px)

DESCRIPTION

very good to read for html will help you

Citation preview

  • 5/30/2015 html5CreatingaZoomEffectonanimageonhoverusingCSS?StackOverflow

    http://stackoverflow.com/questions/15757036/creatingazoomeffectonanimageonhoverusingcss 1/4

    signup login tour help stackoverflowcareers

    Takethe2minutetour StackOverflowisaquestionandanswersiteforprofessionalandenthusiastprogrammers.It's100%free,noregistrationrequired.

    CreatingaZoomEffectonanimageonhoverusingCSS?

    I'mcurrentlytryingtocreateazoomeffectonhoveroveroneofmyfourimages.Theproblemismostexamplesusuallyusetablesormaskdivstoapplysomesortofeffect.

    Here'soneexamplethatimplementswhatIwouldlike .this

    ismycodesofar.This

    Thankssomuch!!

    HTML

    CSS

    #menu{maxwidth:1200px;textalign:center;margin:auto;}

    #menuimg{width:250px;height:375px;padding:0px5px0px5px;overflow:hidden;

    }

    .blog{height:375px;webkittransition:all1sease;moztransition:all1sease;otransition:all1sease;mstransition:all1sease;transition:all1sease;}

    .blog:hover{cursor:pointer;height:475px;width:350px;}

    .music{height:375px;}

    .projects{height:375px;}

    .bio{height:375px;}

    css html5 class css3

    editedDec26'13at5:29neshpro9394 2 15

    askedApr2'13at5:49KingPolygon1,043 4 11 34

    voteupforthelinkyouposted,ithelpedme:) neshpro9 Dec26'13at6:16

    4Answers

  • 5/30/2015 html5CreatingaZoomEffectonanimageonhoverusingCSS?StackOverflow

    http://stackoverflow.com/questions/15757036/creatingazoomeffectonanimageonhoverusingcss 2/4

    Whataboutusing propertyanduse whichillgiveazoomlikeeffect,thiscanbedonelikeso,

    CSS3transform scale

    HTML

    CSS

    .thumbnail{width:320px;height:240px;}

    .image{width:100%;height:100%;}

    .imageimg{webkittransition:all1sease;/*SafariandChrome*/moztransition:all1sease;/*Firefox*/mstransition:all1sease;/*IE9*/otransition:all1sease;/*Opera*/transition:all1sease;}

    .image:hoverimg{webkittransform:scale(1.25);/*SafariandChrome*/moztransform:scale(1.25);/*Firefox*/mstransform:scale(1.25);/*IE9*/otransform:scale(1.25);/*Opera*/transform:scale(1.25);}

    Here'sademo .Iremovedsomeoftheelementtomakeitsimpler,youcanalwaysaddoverflowhiddentothe tohidetheoverflowofthescaledimage.

    fiddle.image

    propertyonlyworksinIEzoom

    editedAug1'14at0:49 answeredApr2'13at6:33MitchLayzell1,406 1 8 20

    5

    Andwinningthe"deeplifelessonsfromcode"award,yourCSSischanting"Allisease,allisease."Nerrolken Nov1'14at0:15

    Hereyougo.

    Demo

    http://jsfiddle.net/27Syr/4/

    HTML

    Yay!

    Yay!

  • 5/30/2015 html5CreatingaZoomEffectonanimageonhoverusingCSS?StackOverflow

    http://stackoverflow.com/questions/15757036/creatingazoomeffectonanimageonhoverusingcss 3/4

    Yay!

    Yay!

    CSS

    #menu{textalign:center;}

    .fader{/*Givingequalsizestoeachelement*/width:250px;height:375px;

    /*Positioningelementsinlines*/display:inlineblock;

    /*Thisisnecessaryforposition:absolutetoworkasdesired*/position:relative;

    /*Preventingzoomedimagestogrowoutsidetheirelements*/overflow:hidden;}

    .faderimg{/*Stretchingtheimagestofillwholeelements*/width:100%;height:100%;

    /*Preventingblankspacebelowtheimage*/lineheight:0;

    /*Aonesecondtransitionwastodisturbingforme*/webkittransition:all0.3sease;moztransition:all0.3sease;otransition:all0.3sease;mstransition:all0.3sease;transition:all0.3sease;}

    .faderimg:hover{/*Makingimagesappearbiggerandtransparentonmouseover*/opacity:0.5;width:120%;height:120%;}

    .fader.text{/*Placingtextbehindimages*/zindex:10;

    /*Positioningtexttopleftconrnerinthemiddleofelements*/position:absolute;top:50%;left:50%;}

    .fader.textp{/*Positioningtextcontents50%leftandtoprelativetotextcontainer'stopleftcorner*/margintop:50%;marginleft:50%;}

    Suggestion

    Insteadof considerusingsomegridsystem.Basedonyourtechnologyofpreference,youcango , , ortheiralternatives.

    .fader{inlineblock;}Foundation Susy Masonry

    answeredApr2'13at6:25lolmausAndreyMikhaylov8,420 2 24 63

    Ilikeusingabackgroundimage.Ifinditeasierandmoreflexible:

    DEMO

    CSS:

  • 5/30/2015 html5CreatingaZoomEffectonanimageonhoverusingCSS?StackOverflow

    http://stackoverflow.com/questions/15757036/creatingazoomeffectonanimageonhoverusingcss 4/4

    #menu{maxwidth:1200px;textalign:center;margin:auto;}.zoomimg{display:inlineblock;width:250px;height:375px;padding:0px5px0px5px;backgroundsize:100%100%;backgroundrepeat:norepeat;backgroundposition:centercenter;transition:all.5sease;}.zoomimg:hover{cursor:pointer;backgroundsize:150%150%;}.blog{backgroundimage:url(http://s18.postimg.org/il7hbk7i1/image.png);}.music{backgroundimage:url(http://s18.postimg.org/4st2fxgqh/image.png);}.projects{backgroundimage:url(http://s18.postimg.org/sxtrxn115/image.png);}.bio{backgroundimage:url(http://s18.postimg.org/5xn4lb37d/image.png);}

    HTML:

    DEMO2withOverlay

    editedAug1'14at1:38 answeredAug1'14at1:10jme116,025 1 4 17

    Iwouldn'trecommendusingabackgroundimageforthis,you'regoingtoloosealltheamazingimagerelatedSEOthatcomeswithusingaimagetagandaltattributes. MitchLayzell Sep1'14at17:54

    Ithinkthisisgreat,butyoudolosealltheutilityoftheimgtag. DanielNaab Sep12'14at2:16

    webkittransition:all1sease;/*SafariandChrome*/moztransition:all1sease;/*Firefox*/mstransition:all1sease;/*IE9*/otransition:all1sease;/*Opera*/transition:all1sease;

    justwanttomakeanoteontheabovetransitionsonlyneed

    webkittransition:all1sease;/*SafariandChrome*/transition:all1sease;

    andmscertainlydoenstworkforIE9idontknowwhereyougotthatideafrom.

    answeredFeb13at10:56DCdaz657 11