2016-10-10 17 views
-3

當用戶點擊任何圓圈時,我想顯示下面的效果。考慮粉紅色的顏色圈。當用戶點擊任何一個圈我想顯示下面的效果。考慮粉紅色圓圈

![enter image description here] 1

的OnClick上的任何圓圈然後我想要繪製如圖在圖像中。

我可以用下面的代碼片段畫圓:

<div className="tableRow"> 
       {this.paletteColors.map((paletteColor) => { 
        return (<li className="color-li"> 
         <div className="circle" 
          style={{ 
           "backgroundColor": paletteColor 
          }} 
          data-colorval={paletteColor} 
          onClick={this.paletteColorClick} 
         > </div> 
        </li>); 
       })} 
      </div> 

.color-li { 
    display: inline-block; 
    position: relative; 
} 

.circle { 
    border-radius: 50%; 
    height: 40px; 
    text-align: center; 
    width: 40px; 
    margin: 0px 12px; 
    line-height: 40px; 
    z-index: 3; 
    position: relative; 
} 
+0

它可能更多的情況下,更改圈,使其更小,然後添加邊框ra而不是「在一個圓圈內畫一個圓圈」。那是你要做的嗎? –

回答

1

box-shadow一點jQuery的可以管理大部分是混合物,background-clipbox-sizing:border-box等和:

(function($) { 
 
    $('.circle').click(function() { 
 
    $(this).toggleClass('open'); 
 
    }); 
 
})(jQuery);
body { 
 
    background: lightgreen; 
 
} 
 
* { 
 
    margin: 0; 
 
    padding: 0; 
 
    box-sizing: border-box; 
 
} 
 
.circle { 
 
    width: 100px; 
 
    height: 100px; 
 
    border-radius: 50%; 
 
    border: 0px solid transparent; 
 
    background-clip: padding-box; 
 
    margin: 3em; 
 
    display: inline-block; 
 
    transition: border-width .3s ease; 
 
    box-shadow: 0 0 0 2px; 
 
} 
 
.circle.red { 
 
    color: red; 
 
    background-color: red; 
 
} 
 
.blue { 
 
    background-color: blue; 
 
    color: blue; 
 
} 
 
.circle.open { 
 
    border-width: 15px !important; 
 
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> 
 
<div class="circle red"></div> 
 

 
<div class="circle blue"></div>