Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Change border-radius of div dynamically

I have a red div in the background with curved borders and a yellow div rendered over it with a curved border too. The yellow bar is slowly filling the red bar (to indicate progress, for example). See this fiddle:

http://jsfiddle.net/a6Xy9/3/

Code

<div id="topDiv" style="height:20px; width:200px; background-color:red; border-radius:10px;">
    <div id="childDiv" style="height:20px; width:100px; background-color:yellow; border-top-left-radius:10px; border-bottom-left-radius:10px;">
    </div>
</div>
<br/>
<br/>    
<input id="change" type="button" value="Change Width" style="height:25px; width:100px;"></input>

$("#change").click(function(){
 $("#childDiv").width((parseInt($("#childDiv").width()) + 5) + "px");
});

Now, what I would like is for the yellow bar's right border to be flat (not curved) when it is not fully filling the red bar. But it should become curved when it fully fills the red bar. Can someone suggest the best way to implement this?

like image 914
Amar Avatar asked Jan 19 '26 17:01

Amar


1 Answers

Just add overflow: hidden to the #topDiv

JSFiddle

like image 133
Steve Sanders Avatar answered Jan 22 '26 06:01

Steve Sanders