English 中文(简体)
2. 如何清理内over的一个要素
原标题:How to animate an element on hover

How can I make my <div> elements grow (以及 the content changes text size to a higher one), when hovered over? I put them in a class 以及 tried:

size: 150%;

以及

height: +30px;
width: +30px;

the first try didn t work at all, 以及 the second code just made the div s flash 以及 dissappear partially.

最佳回答

CSS3解决办法:

div {
    background: #999;
    width: 200px;
    height: 20px; 
    transition: width 1s;
}

div:hover{
    width: 300px;
}
<div>
    <p>Im content</p>
</div>

http://jsfiddle.net/MrdvW/"rel=“nofollow> http://jsfiddle.net/MrdvW/

问题回答

I did something like this for a similar problem (you can change the scale to whatever works for you):

div:hover {
 -webkit-transform: scale(1.1);
 -moz-transform:    scale(1.1);
 -o-transform:      scale(1.1);
 -ms-transform:     scale(1.1);
}

Note that this will scale both the div and its content, which I think is what you want.

借助社保局,你可以在四处添加一 style:

div.container {
    width: 80%;
    background-color: blue;
}

div.container:hover {
    width: 100%;
    background-color: red;
}

See this jsFiddle for a show.

http://www.ohchr.org。

可为您工作的另一个选择是jQuery。 它拥有一个简明文图书馆,简化了诸如此等通常需要的功能。 借助 j,你可以轻松地把 h效应添加到:

//hover effect applies to any elements using the  container  class
$(".container").hover(
    function(){ //mouse over
        $(this).width($(this).width() + 30);
    },
    function(){ //mouse out
        $(this).width($(this).width() - 30);
    }
);

See this jsFiddle for a show.





相关问题
CSS working only in Firefox

I am trying to create a search text-field like on the Apple website. The HTML looks like this: <div class="frm-search"> <div> <input class="btn" type="image" src="http://www....

image changed but appears the same in browser

I m writing a php script to crop an image. The script overwrites the old image with the new one, but when I reload the page (which is supposed to pickup the new image) I still see the old one. ...

Firefox background image horizontal centering oddity

I am building some basic HTML code for a CMS. One of the page-related options in the CMS is "background image" and "stretch page width / height to background image width / height." so that with large ...

Separator line in ASP.NET

I d like to add a simple separator line in an aspx web form. Does anyone know how? It sounds easy enough, but still I can t manage to find how to do it.. 10x!

热门标签