javascript - JS,CSS,jQuery DIV 3D效果

标签 javascript jquery css

我正在寻找一种特定的效果,但我不确定它叫什么或者我应该如何搜索它。

基本上,我追求的是 3D 效果。 我有一个 DIV 元素,我希望它表现得像放在一个球上(位于它的中心下方)。

因此,当您将鼠标悬停在边缘上时,该边缘将缩小/放大。

有没有人见过这样的东西?这完全可以实现吗?

编辑: 行为 in this example best describes what I was after但 DIV 不是文本。 我想我可以根据自己的需要调整此示例。

抱歉,如果我的描述过于笼统,我不确定如何描述我需要的东西。

最佳答案

您可以为此使用 CSS Transition。 使用 css transition,您可以为 div 或对象设​​置动画。

看看这个很棒的教程

https://developer.mozilla.org/en-US/docs/CSS/Tutorials/Using_CSS_transitions

一个例子:

JSFIDDLE

<body>
    <p>The box below combines transitions for: width, height, background-color, transform. Hover over the box to see these properties animated.</p>
    <div class="box"></div>
</body>

.box {
    border-style: solid;
    border-width: 1px;
    display: block;
    width: 100px;
    height: 100px;
    background-color: #0000FF;
    -moz-transition:width 2s, height 2s, background-color 2s, -moz-transform 2s;
    -webkit-transition:width 2s, height 2s, background-color 2s, -webkit-transform 2s;
    -o-transition:width 2s, height 2s, background-color 2s, -o-transform 2s;
    transition:width 2s, height 2s, background-color 2s, transform 2s;
}
.box:hover {
    background-color: #FFCCCC;
    width:200px;
    height:200px;
    -moz-transform:rotate(180deg);
    -webkit-transform:rotate(180deg);
    -o-transform:rotate(180deg);
    transform:rotate(180deg);
}

希望这是你的意思。

关于javascript - JS,CSS,jQuery DIV 3D效果,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16188580/

相关文章:

javascript - 使用 Parsley.js 验证字段后触发代码

javascript - HTML xpath 选择父元素的前一个兄弟

JavaScript:条件(三元)与非 bool 值的 bool 值或?

javascript - 为什么输入更改后提交状态没有立即更新?

javascript - 代码在使用 window.onload 时有效,但在 document.ready 时无效?为什么?

css - 如何定义CSS分层顺序?

javascript - 如何根据一天中的时间替换图像

javascript - jQuery 最后一个子选择器

javascript - 在 CoffeeScript 游戏引擎中使用混合

asp.net - 不使用 AJAX 加载图像