Question

When I do an animated show/hide on the select element it repositions itself during the animation. I can't do anything about the style of the "body"; it's the standard class markup in the app. Is there some simple CSS I can apply to the select element prevent it from repositioning?

Update: Added the third select element to the code and example

example: http://jsfiddle.net/DSULq/8/

<div id="body" style="position: absolute; top: 100px;">
    <div id="toolbar" style="background-color: grey; width: 400px;">
        <select>
            <option>A</option>
            <option>B</option>
            <option>C</option>
            <option>D</option>
            <option>E</option>
        </select>
        <select id="toggleMe">
            <option>A</option>
            <option>B</option>
            <option>C</option>
            <option>D</option>
            <option>E</option>
        </select>
        <select>
            <option>A</option>
            <option>B</option>
            <option>C</option>
            <option>D</option>
            <option>E</option>
        </select>
    </div>
<div>
<button>do effect</button>

$("button").click(function () {
    if ($("#toggleMe").is(":visible")) {
        $("#toggleMe").hide("slide", "slow");
    } else {
        $("#toggleMe").show("slide", "slow");
    }
});
Was it helpful?

Solution

How about this:

$("button").click(function () {
    $("#toggleMe").fadeToggle("slow");
});

DEMO

OTHER TIPS

Just use a fixed position for #toggleMe:

CSS:

 #toggleMe {
     position: fixed;
     top: 100px;
     left: 50px;
 }

http://jsfiddle.net/jk46K/1/

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top