7
我想用我的6個按鈕創建一個帶有距離的圓。在圖片中你可以看到我的嘗試結果,但它看起來不像一個圓圈。我用紅色圈出了我的問題。下面你可以看看我的HTML和CSS代碼。
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
<style>
.container {
margin-top: 360px;
margin-bottom: 16px;
padding-left: 30px;
padding-right: 30px;
}
.top-left {
\t margin-top: -260px;
\t margin-left: -20px;
\t border-radius: 40px/100px;
\t border-top-right-radius: 0;
\t border-bottom-right-radius: 0;
\t border-bottom-left-radius: 0;
\t position: absolute;
}
.top-right {
\t margin-top: -260px;
\t margin-left: 155px;
\t border-radius: 40px/100px;
\t border-bottom-left-radius: 0;
\t border-top-left-radius: 0;
\t border-bottom-right-radius: 0;
\t position: absolute;
}
.bottom-left {
\t margin-top: -160px;
\t margin-left: -20px;
\t border-radius: 40px/100px;
\t border-top-right-radius: 0;
\t border-top-left-radius: 0;
\t border-bottom-right-radius: 0;
\t position: absolute;
}
.bottom-right {
\t margin-top: -160px;
\t margin-left: 155px;
\t border-radius: 40px/100px;
\t border-top-right-radius: 0;
\t border-top-left-radius: 0;
\t border-bottom-left-radius: 0;
\t position: absolute;
}
.top-center{
\t border-radius: 440px/220px;
\t border-bottom-left-radius: 0;
\t border-bottom-right-radius: 0;
\t width: 270px!important;
\t height: 70px!important;
\t margin-top: -334px;
\t margin-left: 15px;
\t position: absolute;
}
.top-center p {
\t padding: 0px 40px 0px 40px;
}
.bottom-center{
\t border-radius: 440px/220px;
\t border-top-left-radius: 0;
\t border-top-right-radius: 0;
\t width: 270px!important;
\t height: 70px!important;
\t margin-top: -64px;
\t margin-left: 15px;
\t position: absolute;
}
.bottom-center p {
\t padding: 0px 40px 0px 40px;
}
.div-button {
\t width: 168px;
\t height: 92px;
\t border: 2px solid rgba(77,207,255,1);
\t background-color: transparent;
color: rgba(77,207,255,1);
font-size: 25px;
text-align: center;
\t vertical-align: middle;
\t line-height: 100px;
\t transition: all .3s linear;
}
.div-button p{
\t margin-top: -10px!important;
\t text-overflow: ellipsis;
\t white-space: nowrap;
\t overflow: hidden;
}
.button-selected {
\t transform: scale(0.8);
\t border: none;
\t background-color: rgba(77,207,255,1);
\t color: black;
}
</style>
</head>
<body>
<div class="container">
\t <div class="div-button top-center" id="top-center">
\t \t <p>Text</p>
\t </div>
\t <div class="div-button top-left" id="top-left">
\t \t <p>Text</p>
\t </div>
\t <div class="div-button top-right" id="top-right">
\t \t <p>Text</p>
\t </div>
\t <div class="div-button bottom-left" id="bottom-left">
\t \t <p>Text</p>
\t </div>
\t <div class="div-button bottom-right" id="bottom-right">
\t \t <p>Text</p>
\t </div>
\t <div class="div-button bottom-center" id="bottom-center">
\t \t <p>Text</p>
\t </div>
</div>
</body>
</html>
既然你有高度和寬度靜態值。你爲什麼不添加一個能夠勾勒出div的圖像/背景?然後將它們放在容器中。這是最簡單的解決方案。但是如果你不想要圖像,那麼玩邊框值就很有趣。 – pol
我不想要圖片。但是我邊玩邊框值,從未收到預期的結果...... ^^ –
您可以使用SVG並繪製您喜歡的路徑。 – pol