Reputation: 1668
Hi I created a slider in which I want to give a button to the slider Which should look like this
I created The Button To the slider with the following code.all looks good
#sliderdiv
{
top:30%;
right: -2px;
position:fixed;
width:300px;
height:270px;
margin-right: -300px;
}
#buttondiv
{
height:110px;
width:40px;
background:aqua;
position:absolute;
float:left;
margin-left: -39px;
}
<div id="sliderdiv">
<div id="buttondiv">
</div>
</div>
Now when the width of the slider changes the button moves from it like this
I Know This is because of the margin-left value which i give to the button div.Here is the question i have is there a way to position it correctly even when the slider div is automatically changed?
Or Is there a way to place the button to slider div without any gap and without changing the button div values?
Thanks...
Here is the Fiddle http://jsfiddle.net/sNgxR/3/
Upvotes: 0
Views: 442
Reputation: 1408
check this out:
var mywidth = $("#buttondiv").width();
$("#buttondiv").css("margin-left", -mywidth);
edit the Width of your button and hit run.
if you change the val of the slider, it works fine
Upvotes: 1