0

当我的按钮悬停时,我想向上滑动一个新的输入字段,这样它看起来就像它来自按钮后面。

首先,我试图只使用 CSS。因此,我尝试使用overflow: hidden. 但是当我这样做时,按钮会淡出而不是输入字段。有什么办法可以改变这个吗?喜欢特定的浏览器吗?这么多。

现在我尝试使用 jQuery,但我不习惯这样做。我真的希望你有一个让它正常工作的想法。

需要更改的值是margin : 0 auto -3pxto0 auto -31px

这是我的例子

4

2 回答 2

2

如果您创建一个周围的 div,这可以在没有 javascript 的情况下完成。

我创建了一个带有“一些”类的 div(缺乏创造力)。然后,当您将其悬停时,输入字段变为可见。

CSS:

.some {
    display: inline-block;
}

.some:hover .l-input {
    margin: 0 auto -3px; 
}

.l-button {
    text-transform: uppercase;
margin: 0 auto;
display: block;
width: 7em;
position: relative;
    cursor: pointer;
 }

.l-input {
margin: 0 auto -31px;
text-align: center;
text-transform: uppercase;
width: 5.9em;
position: relative;
height: 1.25em;
    display: block;
 }

小提琴:http: //jsfiddle.net/c3Veu/

编辑:

看看这个:http: //jsfiddle.net/sbNym/

改为使用绝对位置,因此输入字段从后面弹出。(:

于 2013-10-27T14:08:42.713 回答
0

试试这个HTML

    <div id="container">
        <input type="text" name="bewerbung" class="l-input">
        <button type="button" value="BSend" class="l-button">code</button>
    </div>

Script

        $(document).ready(function () {

            $('.l-button').mouseover(function () {
                $('.l-input').animate({ bottom: '40px' });
            });
            $('.l-input').mouseleave(function () {
                $('.l-input').animate({ bottom: '6px' });
            });
        });

CSS

        body {
            padding: 5em;
        }

        /*NEW*/
        #container {
            position: relative;
            width: 90px;
        }
        /*NEW*/

        input {
            background: transparent;
            border: 1px solid rgba(155,86,77,0.2);
            border-width: 0 0 1px;
            -webkit-border-radius: 3px;
            -moz-border-radius: 3px;
            -o-border-radius: 3px;
            border-radius: 3px;
            padding: 5px;
            background: linear-gradient(to bottom, rgba(0,0,0,0.1) 0%,rgba(255,255,255,0.1) 100%);
            background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,rgba(0,0,0,0.1)), color-stop(100%,rgba(255,255,255,0.1)));
            background: -o-linear-gradient(top, rgba(0,0,0,0.1) 0%,rgba(255,255,255,0.1) 100%);
            background: -ms-linear-gradient(top, rgba(0,0,0,0.1) 0%,rgba(255,255,255,0.1) 100%);
            background: -moz-linear-gradient(top, rgba(0,0,0,0.1) 0%, rgba(255,255,255,0.1) 100%);
            background: -webkit-linear-gradient(top, rgba(0,0,0,0.1) 0%,rgba(255,255,255,0.1) 100%);
            filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#1a000000', endColorstr='#1affffff',GradientType=0 );
            -webkit-box-shadow: 1px 1px 1px rgba(0, 0, 0, 0.2) inset, -1px -1px 1px rgba(255,255,255,0.2) inset, -1px 0px 1px rgba(0, 0, 0, 0.2) inset, 0 3px 0 rgba(155,86,77,0.8);
            -moz-box-shadow: 1px 1px 1px rgba(0, 0, 0, 0.2) inset, -1px -1px 1px rgba(255,255,255,0.2) inset, -1px 0px 1px rgba(0, 0, 0, 0.2) inset, 0 3px 0 rgba(155,86,77,0.8);
            -ms-box-shadow: 1px 1px 1px rgba(0, 0, 0, 0.2) inset, -1px -1px 1px rgba(255,255,255,0.2) inset, -1px 0px 1px rgba(0, 0, 0, 0.2) inset, 0 3px 0 rgba(155,86,77,0.8);
            -o-box-shadow: 1px 1px 1px rgba(0, 0, 0, 0.2) inset, -1px -1px 1px rgba(255,255,255,0.2) inset, -1px 0px 1px rgba(0, 0, 0, 0.2) inset, 0 3px 0 rgba(155,86,77,0.8);
            box-shadow: 1px 1px 1px rgba(0, 0, 0, 0.2) inset, -1px -1px 1px rgba(255,255,255,0.2) inset, -1px 0px 1px rgba(0, 0, 0, 0.2) inset, 0 3px 0 rgba(155,86,77,0.8);
            font-family: Raleway;
            -webkit-appearance: none;
            -moz-appearance: none;
            appearance: none;
            outline: none;
            -webkit-tap-highlight-color: rgba(0, 0, 0, 0);
            -webkit-tap-highlight-color: transparent;
            -webkit-tap-highlight: none;
            -webkit-focus-ring-color: rgba(0, 0, 0, 0);
            -webkit-focus-ring-color: transparent;
            -webkit-focus-ring-color: none;
        }

        .l-input:active, .l-input:focus {
            -webkit-box-shadow: 1px 1px 1px rgba(0, 0, 0, 0.2) inset, -1px -1px 1px rgba(255,255,255,0.2) inset, -1px 0px 1px rgba(0, 0, 0, 0.2) inset, 0 0 1px 4px rgba(105,157,182,0.3), 0 4px 0 rgba(155,86,77,0.8);
            -moz-box-shadow: 1px 1px 1px rgba(0, 0, 0, 0.2) inset, -1px -1px 1px rgba(255,255,255,0.2) inset, -1px 0px 1px rgba(0, 0, 0, 0.2) inset, 0 0 1px 4px rgba(105,157,182,0.3), 0 4px 0 rgba(155,86,77,0.8);
            -ms-box-shadow: 1px 1px 1px rgba(0, 0, 0, 0.2) inset, -1px -1px 1px rgba(255,255,255,0.2) inset, -1px 0px 1px rgba(0, 0, 0, 0.2) inset, 0 0 1px 4px rgba(105,157,182,0.3), 0 4px 0 rgba(155,86,77,0.8);
            -o-box-shadow: 1px 1px 1px rgba(0, 0, 0, 0.2) inset, -1px -1px 1px rgba(255,255,255,0.2) inset, -1px 0px 1px rgba(0, 0, 0, 0.2) inset, 0 0 1px 4px rgba(105,157,182,0.3), 0 4px 0 rgba(155,86,77,0.8);
            box-shadow: 1px 1px 1px rgba(0, 0, 0, 0.2) inset, -1px -1px 1px rgba(255,255,255,0.2) inset, -1px 0px 1px rgba(0, 0, 0, 0.2) inset, 0 0 1px 4px rgba(105,157,182,0.3), 0 4px 0 rgba(155,86,77,0.8);
        }

        button {
            display: inline-block;
            color: #FFF;
            background: #699DB6;
            padding: 7px 20px;
            border-radius: 5px;
            border: 1px solid rgba(0,0,0,0.3);
            border-bottom-width: 3px;
        }

        .l-button {
            text-transform: uppercase;
            margin: 0 auto;
            display: block;
            width: 7em;
            position: relative;
            cursor: pointer;
        }

        .l-input {
            margin: 0 auto -3px;
            text-align: center;
            text-transform: uppercase;
            width: 5.9em;
            position: absolute;            /*NEW*/
            bottom: 6px;            /*NEW*/
            height: 1.25em;
            display: block;
        }
于 2013-10-27T14:02:04.537 回答