2013-10-28 118 views

回答

2

使用CSS邊界半徑和箱陰影

<div class=social></div> 

演示:http://jsfiddle.net/vS7bS/4/

.social{ 
    margin: 100px; 
width: 150px; 
height: 150px; 
position: relative; 
background: green; 
border-radius: 100%; 
border: 2px solid black; 
    overflow:hidden; 
box-shadow: 100px 0 0 -2px blue, 100px 0 0px 0px black; 
} 
.social:after{ 
    content: ''; 
position: absolute; 
left: 100px; 
top: 0; 
width: 100%; 
height: 100%; 
border-radius: 100%; 
background: red; 
box-shadow: 0 0 0 2px black; 

} 

enter image description here

演示2:http://jsfiddle.net/vS7bS/5/

演示用:懸停http://jsfiddle.net/vS7bS/6/

<div class=social> 
    <section> 
    <div></div> 
    <div></div> 
    </section> 
    <div></div> 
</div> 

CSS

section{ 
    position:relative; 
    width:150px; 
    height:150px; 
    overflow:hidden; 
    border-radius:100%; 
    box-shadow: 0 0 0 2px black; 
    z-index: 10; 
} 

section div{ 
    width: 170px; 
    height: 170px; 
    border-radius:100%; 
    border:2px solid black; 
    position:absolute; 
} 
section div:nth-child(1):hover{ 
    background:orange; 
} 
section div:nth-child(2):hover{ 
    background:#333; 
} 
section div:nth-child(1){ 
    left: -8px; 
top: -3px; 
background: blue; 
} 
section div:nth-child(2){ 
    width: 150px; 
height: 150px; 
border-radius: 100%; 
border: 2px solid black; 
background: red; 
right: -76px; 
position: absolute; 
} 

.social{ 
    position:relative; 
    width: 156px; 
    height: 156px; 

    margin:100px; 
} 

.social >div{ 
    width: 150px; 
height: 150px; 
border-radius: 100%; 
border: 2px solid black; 
background: yellow; 
right: -70px; 
top: 0; 
position: absolute; 
z-index: 1; 
} 

.social >div:hover{ 
    background:skyblue; 
} 
+0

這很好!但我需要這個區域是可選的。爲了測試可以說,當我將鼠標懸停在該區域上時,它應該變成黃色。這種方法可能嗎? – mattmuirhead

+0

然後使用3格我會更新它 –

+0

基本上我希望這些中間部分可以選擇在這個http://jsfiddle.net/mattmuirhead/ZXgwb/ – mattmuirhead

0

試試這個

jsfiddle DEMO

結果enter image description here

#shape { 
    position:absolute; 
    top:100px; 
    left:100px; 
    width: 80px; 
    height: 80px; 
    background: blue; 
    margin: 3px 0 0 30px; 
    /* Rotate */ 
    -webkit-transform: rotate(-45deg); 
    -moz-transform: rotate(-45deg); 
    -ms-transform: rotate(-45deg); 
    -o-transform: rotate(-45deg); 
    transform: rotate(-45deg); 
    /* Rotate Origin */ 
    -webkit-transform-origin: 0 100%; 
    -moz-transform-origin: 0 100%; 
    -ms-transform-origin: 0 100%; 
    -o-transform-origin: 0 100%; 
    transform-origin: 0 100%; 
    -moz-border-radius: 60px 0px; 
    -webkit-border-radius: 60px 0px; 
    border-radius: 80px 0px; 
}