2016-12-28 21 views
7

Gear ScreenshotNhiều nút cho một vòng kết nối

Tôi muốn tạo vòng kết nối có khoảng cách bằng 6 nút. Trong hình ảnh bạn có thể thấy kết quả thử của tôi nhưng nó không giống như một vòng tròn. Tôi khoanh tròn vấn đề của mình với màu đỏ. Dưới đây bạn có thể xem xét mã HTML và CSS của tôi.

<!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>

+1

Vì bạn có giá trị tĩnh cho chiều cao và chiều rộng. Tại sao bạn không chỉ cần thêm một hình ảnh/nền mà sẽ phác thảo các divs. Sau đó định vị chúng trong thùng chứa. Đó là giải pháp đơn giản nhất. Nhưng nếu bạn không muốn một hình ảnh, sau đó vui chơi với các giá trị biên giới. – pol

+1

Tôi không muốn một hình ảnh. Nhưng tôi chơi arround với các giá trị biên giới và không bao giờ nhận được kết quả mong đợi ... ^^ –

+2

Bạn có thể sử dụng SVG và vẽ đường dẫn bạn thích. – pol

Trả lời

5

Như đã đề cập trong các ý kiến, tuyến đường svg là cách dễ nhất tái tạo những gì bạn muốn một cách nhanh chóng.

Tuy nhiên, thích thử thách, tôi đã sử dụng overflow:hiddenposition:absolute để che giấu hiệu quả các phần khác nhau.

Tôi đã tạo bút here.

Bất kỳ nội dung nào bạn muốn đặt bên trong các phần sẽ cần phải đi trong phạm vi .circle div.

Tôi hy vọng điều này phù hợp với những gì bạn muốn.

.circle-container { 
 
      position:relative; 
 
      display:block; 
 
      width:400px; 
 
      height:400px; 
 
      margin:auto; 
 
     } 
 
     
 
     .circle-crop-top { 
 
      width: 100%; 
 
      height: 25%; 
 
      display:block; 
 
      overflow:hidden; 
 
     } 
 
     
 
     .circle-first-left, .circle-first-right, .circle-second-left, .circle-second-right { 
 
      float:left; 
 
      width: 50%; 
 
      height: 25%; 
 
      overflow: hidden; 
 
      white-space: nowrap; 
 
     } 
 
     .circle-bottom { 
 
      width:100%; 
 
      height:25%; 
 
      display: block; 
 
      overflow:hidden; 
 
     } 
 
     .circle-parent { 
 
      position:relative; 
 
     } 
 
     .circle-parent p { 
 
      position:absolute; 
 
      text-align:center; 
 
      margin:0; 
 
     } 
 
     .circle { 
 
      width:396px; 
 
      height:396px; 
 
      border-radius:50%; 
 
      position: absolute; 
 
      top:0; 
 
      border:2px solid blue; 
 
      text-align: center; 
 
      overflow:hidden; 
 
     } 
 
     .circle-first-left .circle { 
 
      top:-100px; 
 
     } 
 
     .circle-first-right .circle { 
 
      top:-100px; 
 
      right: 0; 
 
     } 
 
     .circle-second-left .circle { 
 
      top:-200px; 
 
     } 
 
     .circle-second-right .circle { 
 
      top:-200px; 
 
      right: 0; 
 
     } 
 
     .circle-bottom .circle { 
 
      top:-300px; 
 
      right: 0; 
 
     } 
 
     .circle-crop-top p { 
 
      margin:0; 
 
      border: 2px solid blue; 
 
      width: 100%; 
 
      height: 50px; 
 
      padding-top: 40px; 
 
      text-align: center; 
 
      top: -2px; 
 
     } 
 
     .circle-first-left p { 
 
      border: 2px solid blue; 
 
      width: 192px; 
 
      height: 60px; 
 
      margin:10px 0 10px 0; 
 
      padding-top: 30px; 
 
      text-align: center; 
 
      top: 23%; 
 
      left:-2px; 
 
     } 
 
     .circle-first-right p { 
 
      border: 2px solid blue; 
 
      width: 192px; 
 
      margin:10px 0 10px 0; 
 
      height: 60px; 
 
      padding-top: 30px; 
 
      text-align: center; 
 
      top: 23%; 
 
      right:-2px; 
 
     } 
 
     .circle-second-left p { 
 
      border: 2px solid blue; 
 
      width: 192px; 
 
      height: 60px; 
 
      margin:10px 0 10px 0; 
 
      padding-top: 30px; 
 
      text-align: center; 
 
      top: 48%; 
 
      left:-2px; 
 
     } 
 
     .circle-second-right p { 
 
      border: 2px solid blue; 
 
      width: 192px; 
 
      margin:10px 0 10px 0; 
 
      height: 60px; 
 
      padding-top: 30px; 
 
      text-align: center; 
 
      top: 48%; 
 
      right:-2px; 
 
     } 
 
     .circle-bottom p { 
 
      margin:0; 
 
      border: 2px solid blue; 
 
      width: 100%; 
 
      height: 60px; 
 
      padding-top: 40px; 
 
      text-align: center; 
 
      top: 76%; 
 
     }
<div class="circle-container"> 
 
     <div class="circle-crop-top"> 
 
      <div class="circle-parent"> 
 
       <div class="circle"><p>Luzern</p></div> 
 
      </div> 
 
     </div> 
 
     <div class="circle-first-left"> 
 
      <div class="circle-parent"> 
 
       <div class="circle"><p>Bern</p></div> 
 
      </div> 
 
     </div> 
 
     <div class="circle-first-right"> 
 
      <div class="circle-parent"> 
 
       <div class="circle"><p>Zurich</p></div> 
 
      </div> 
 
     </div> 
 
     <div class="circle-second-left"> 
 
      <div class="circle-parent"> 
 
       <div class="circle"><p>Basel</p></div> 
 
      </div> 
 
     </div> 
 
     <div class="circle-second-right"> 
 
      <div class="circle-parent"> 
 
       <div class="circle"><p>Genf</p></div> 
 
      </div> 
 
     </div> 
 
     <div class="circle-bottom"> 
 
      <div class="circle-parent"> 
 
       <div class="circle"><p>Saas-Fee, Alpin</p></div> 
 
      </div> 
 
     </div> 
 
    </div>

+0

làm thế nào để làm cho nó đáp ứng? :-) – Legends

Các vấn đề liên quan