Искам да .animate css свойство за позиция от position : relative
до position : absolute
с jQuery.
Имам малък div вътре в контейнера div и искам да разширя този div, когато щракна върху бутон, за да пасне на прозореца.
HTML:
<div id="container"> <!-- div with position:relative -->
<div id="content"> <!-- i want to expand this div using position:absolute to extract it from the container and to give width and height 100% -->
<button id="full">Full</button>
<button id="collapse">Collapse</button>
</div>
</div>
Аз тренирам с jQuery().animate
, но не работи и тренирам с jQuery().css
и работи, но не както искам.
Това направих:
$(document).ready(function () {
$("#collapse").hide();
$("#full").bind("click", function (e) {
e.preventDefault();
$("#content").animate({
width: "1000px",
height:"1000px",
top:0,
left:0
}, 500).css({"overflow": "visible", "position":"absolute"});
$("#full").hide(100);
$("#collapse").show(100); // can i use $("#collapse").css("display","block"); ?
});
$("#collapse").bind("click", function (e) {
e.preventDefault();
$("#content").animate({
width: "400px",
height: "300px",
}, 500).css({"overflow": "visible", "position":"relative"});
$("#full").show(100);
$("#collapse").hide(100);
});
});
Благодаря ви много за всяка помощ!
Най-добри поздрави.