<bdo id='1Bt9k'></bdo><ul id='1Bt9k'></ul>

        <small id='1Bt9k'></small><noframes id='1Bt9k'>

      1. <tfoot id='1Bt9k'></tfoot>
        <i id='1Bt9k'><tr id='1Bt9k'><dt id='1Bt9k'><q id='1Bt9k'><span id='1Bt9k'><b id='1Bt9k'><form id='1Bt9k'><ins id='1Bt9k'></ins><ul id='1Bt9k'></ul><sub id='1Bt9k'></sub></form><legend id='1Bt9k'></legend><bdo id='1Bt9k'><pre id='1Bt9k'><center id='1Bt9k'></center></pre></bdo></b><th id='1Bt9k'></th></span></q></dt></tr></i><div id='1Bt9k'><tfoot id='1Bt9k'></tfoot><dl id='1Bt9k'><fieldset id='1Bt9k'></fieldset></dl></div>
        <legend id='1Bt9k'><style id='1Bt9k'><dir id='1Bt9k'><q id='1Bt9k'></q></dir></style></legend>
      2. CSS 背景图片大小转换

        CSS Background image size transition(CSS 背景图片大小转换)
          • <bdo id='pZPox'></bdo><ul id='pZPox'></ul>
            • <small id='pZPox'></small><noframes id='pZPox'>

              <legend id='pZPox'><style id='pZPox'><dir id='pZPox'><q id='pZPox'></q></dir></style></legend>

                  <tbody id='pZPox'></tbody>
                • <tfoot id='pZPox'></tfoot>
                  <i id='pZPox'><tr id='pZPox'><dt id='pZPox'><q id='pZPox'><span id='pZPox'><b id='pZPox'><form id='pZPox'><ins id='pZPox'></ins><ul id='pZPox'></ul><sub id='pZPox'></sub></form><legend id='pZPox'></legend><bdo id='pZPox'><pre id='pZPox'><center id='pZPox'></center></pre></bdo></b><th id='pZPox'></th></span></q></dt></tr></i><div id='pZPox'><tfoot id='pZPox'></tfoot><dl id='pZPox'><fieldset id='pZPox'></fieldset></dl></div>
                  本文介绍了CSS 背景图片大小转换的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  I am working on a simple markup with resizing a div's background img. See the fiddle:

                  http://jsfiddle.net/zeYZL/

                  I need this to be animated with a simple CSS transition. and I tried doing this:

                  #tile:hover {
                      background-size:550px 550px;
                      background-position:-50px -50px;
                      transition:all 0.5s ease;
                      -webkit-transition:all 0.5s ease;
                      -o-transition:all 0.5s ease;
                      -moz-transition:all 0.5s ease;
                  
                  }
                  

                  But then the background image clips upon the hover. (See http://jsfiddle.net/5Hm9u/)

                  Any tips on how to fix it?

                  Greetings, Chris

                  解决方案

                  JSFiddle

                  You need to put background properties outside the hover too, so it knows what to return to when not on hover.

                  e.g.

                  .tile{
                    float:left;
                    margin:1px;
                    width:450px;
                    height:450px;
                    overflow:hidden;
                    background-size:450px 450px;
                    background-position:0px 0px;
                  }
                  

                  And if you want it to transition on mouseover and when you take the mouse off, you put the transition on .tile and not .tile:hover

                  JSFiddle

                  Side note

                  You should avoid using inline styles where you can use a stylesheet. Put your background image in .tile rather than using the style attribute.

                  Full CSS:

                  .tile{
                    float:left;
                    margin:1px;
                    width:450px;
                    height:450px;
                    overflow:hidden;
                    background-size:450px 450px;
                    background-image:url(http://www.placehold.it/450x450);
                    background-position:0px 0px;
                    transition:all 0.5s ;
                    -webkit-transition:all 0.5s ;
                    -o-transition:all 0.5s ;
                    -moz-transition:all 0.5s ;
                  }
                  
                  .tile:hover {
                    background-size:550px 550px;
                    background-position:-50px -50px;
                  }
                  

                  这篇关于CSS 背景图片大小转换的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  Scale background image to fit ie8 window(缩放背景图像以适合 ie8 窗口)
                  @fontface in IE7 (IETEster) not working properly(IE7 (IETEster) 中的@fontface 无法正常工作)
                  Safari 5.1 breaks CSS table cell spacing(Safari 5.1 打破 CSS 表格单元格间距)
                  How to delegate `hover()` function by using `on()`(如何使用 `on()` 委托 `hover()` 函数)
                  How to center slider in css?(如何在css中居中滑块?)
                  Show slider range value on top of thumb(在拇指顶部显示滑块范围值)
                  • <i id='2xerx'><tr id='2xerx'><dt id='2xerx'><q id='2xerx'><span id='2xerx'><b id='2xerx'><form id='2xerx'><ins id='2xerx'></ins><ul id='2xerx'></ul><sub id='2xerx'></sub></form><legend id='2xerx'></legend><bdo id='2xerx'><pre id='2xerx'><center id='2xerx'></center></pre></bdo></b><th id='2xerx'></th></span></q></dt></tr></i><div id='2xerx'><tfoot id='2xerx'></tfoot><dl id='2xerx'><fieldset id='2xerx'></fieldset></dl></div>

                    <legend id='2xerx'><style id='2xerx'><dir id='2xerx'><q id='2xerx'></q></dir></style></legend>
                          <tfoot id='2xerx'></tfoot>
                            <bdo id='2xerx'></bdo><ul id='2xerx'></ul>

                            <small id='2xerx'></small><noframes id='2xerx'>

                              <tbody id='2xerx'></tbody>