2016-10-29 84 views
-5

這個圈子周圍不得有可點擊的區域,我該怎麼做?如何在物體周圍創建不可點擊的區域?

.circ { 
 
    position: absolute; 
 
    left: 50%; 
 
    top: 50%; 
 
    width: 400px; 
 
    height: 400px; 
 
    border-radius: 50%; 
 
    background: red; 
 
    overflow: hidden; 
 
    transform: translate(-50%, -50%); 
 
} 
 
.circ .sub-1, 
 
.circ .sub-2 { 
 
    position: absolute; 
 
    width: 200px; 
 
    height: 200px; 
 
    background: green; 
 
} 
 
.circ .sub-1 a, 
 
.circ .sub-2 a { 
 
    position: relative; 
 
    display: block; 
 
    width: 100%; 
 
    overflow: hidden; 
 
    height: 100%; 
 
    background: yellow; 
 
} 
 
.sub-2 { 
 
    bottom: 0; 
 
    right: 0; 
 
}
<div class="circ"> 
 
    <div class="sub-1"> 
 
    <a href="#"></a> 
 
    </div> 
 
    <div class="sub-2"> 
 
    <a href="#"></a> 
 
    </div> 
 
</div>

+0

非常感謝人! –

+0

其實,你的代碼在Edge/Firefox中工作,但不是Chrome,它具有剪裁和邊框半徑的歷史記錄:http://stackoverflow.com/questions/29101743/inconsistent-selectable-area-of-elements-with-border -radius – LGSon

+0

檢查舊的答案,並找到它。我更新了我的答案,其中也包含了一個可以在Chrome上運行的示例,所以如果您可以查看它,並且它能夠正常運行/接受它。 – LGSon

回答

0

更新

它應該原樣,在邊緣和Firefox和兩個工作測試,雖然Chrome瀏覽器(也許其他基於WebKit的瀏覽器也是如此)有一個問題早與不clipping border radius,並在你的情況下,他們似乎仍然如此。

下面是一個解決方法,即工作的簡化版本,旋轉30度。

訣竅,使其在Chrome瀏覽器(假設所有的基於WebKit的瀏覽器)是:

  • 對DIV circ和主持人a
  • 舉動不使用position 2:第二使用錨保證金代替的position

.wrap { 
 
    position: absolute; 
 
    left: 50%; 
 
    width: 400px; 
 
    height: 400px; 
 
    transform: translateX(-50%) rotate(30deg); 
 
} 
 
.circ { 
 
    width: 100%; 
 
    height: 100%; 
 
    border-radius: 50%; 
 
    background: red; 
 
    overflow: hidden; 
 
} 
 
.circ a { 
 
    display: block; 
 
    width: 50%; 
 
    height: 50%; 
 
    background: yellow; 
 
} 
 
.circ a + a { 
 
    margin-left: 50%; 
 
}
<div class="wrap"> 
 
    <div class="circ"> 
 
    <a href="#"></a> 
 
    <a href="#"></a> 
 
    </div> 
 
</div>

+0

我們有這個圈子有很多輪換轉換的情況。裏面有從2〜6的小孩數。因此,我們現在甚至沒有使用border-left-left-radius:100%; ,因爲它動態變化 –

+0

副作用 –

+0

@ІвченкоДима該信息至關重要,而且由於您沒有在最初的問題中發佈該信息,因此您需要準確顯示發生的情況。正如我上面評論的那樣,Chrome有問題,但可能有一種方法,根據您最終的結果 – LGSon