Как сделать всплывающее окно div всплывающей над ссылкой в ​​JQuery? - PullRequest
7 голосов
/ 11 марта 2011

Как сделать всплывающее окно всплывающей над ссылкой в ​​JQuery?

<div id="floatbar">
    <a href="" onclick="make it float 10px under this yay">
</div>

Ответы [ 3 ]

12 голосов
/ 11 марта 2011

JQuery

$("#floatbar").click(function(e){
    e.preventDefault();
    $(this).find(".popup").fadeIn("slow");
});

КСС

#floatbar {
    position:relative;
}

.popup {
    position:absolute;
    top:10px;
    left:0px;
    height:30px;
    background:#ccc;
    display:none;
}

HTML

<a id="floatbar" href="#">
    <div class="popup">Hi there</div>
    click here
</a>
11 голосов
/ 11 марта 2011

Pure css solution:

<div id="floatbar">
    <a href="" onclick="make it float 10px under this yay">Link</a>
    <div class="box">Popup box</div>
</div>

.box {
     display:none;
     position: absolute;
     top: 30px; 
     left: 10px;
    background: orange;
    padding: 5px;
    border: 1px solid black;
}

a:hover + .box {
     display:block;   
}

Все, что вам нужно сделать, это добавить <div class="box">(popup text)</div> под ссылкой, и она будет работать для каждой ссылки, имеющей такое поле.

http://jsfiddle.net/mcdqt/

1 голос
/ 11 марта 2011

Возможно, это проще, когда вы используете что-то вроде Fancybox для jQuery или другую альтернативу Lightbox?

...