向上滑动输入字段

时间:2013-10-27 13:49:06

标签: jquery css3 css-transitions

当我的按钮徘徊时,我想向上滑动一个新的输入字段,以便它看起来像是从按钮后面来的。

首先,我试图仅使用CSS进行此操作。因此,我尝试使用overflow: hidden处理包围的表单高度。 但是当我这样做时,按钮会变淡而不是输入字段。有没有办法改变这个?喜欢特定的浏览器吗? 这么多。

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

需要更改的值为保证金0 auto -3px0 auto -31px

这是我的example

2 个答案:

答案 0 :(得分:2)

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

我创建了一个带有“some”类的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/

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

答案 1 :(得分: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;
        }