溫馨提示×

溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊×
其他方式登錄
點擊 登錄注冊 即表示同意《億速云用戶服務條款》

css3怎樣實現(xiàn)元素環(huán)繞中心點布局

發(fā)布時間:2022-03-05 09:46:55 來源:億速云 閱讀:146 作者:小新 欄目:web開發(fā)

這篇文章主要介紹css3怎樣實現(xiàn)元素環(huán)繞中心點布局,文中介紹的非常詳細,具有一定的參考價值,感興趣的小伙伴們一定要看完!

  代碼實現(xiàn):

  <style>

  *{

  margin:0;

  padding:0;

  box-sizing:border-box;

  }

  .surround-box,

  .center-point{

  position:absolute;

  top:50%;

  left:50%;

  width:20px;

  height:20px;

  margin-left:-10px;

  margin-top:-10px;

  border-radius:50%;

  background-color:#000;

  }

  .circle{

  /*這里一定要絕對定位,這樣位置才能鋪開來*/

  position:absolute;

  top:-10px;

  left:-10px;

  width:40px;

  height:40px;

  line-height:40px;

  border-radius:50%;

  text-align:center;

  color:#fff;

  }

  .circle1{

  background-color:red;

  /*rotateZ控制方向,每個元素旋轉30度,12個元素剛好360度。translateY控制每個元素距中心點的距離*/

  transform:rotateZ(30deg)translateY(80px);

  }

  .circle2{

  background-color:orange;

  transform:rotateZ(60deg)translateY(80px);

  }

  .circle3{

  background-color:yellow;

  transform:rotateZ(90deg)translateY(80px);

  }

  .circle4{

  background-color:green;

  transform:rotateZ(120deg)translateY(80px);

  }

  .circle5{

  background-color:seagreen;

  transform:rotateZ(150deg)translateY(80px);

  }

  .circle6{

  background-color:blue;

  transform:rotateZ(180deg)translateY(80px);

  }

  .circle7{

  background-color:purple;

  transform:rotateZ(210deg)translateY(80px);

  }

  .circle8{

  background-color:lightsalmon;

  transform:rotateZ(240deg)translateY(80px);

  }

  .circle9{

  background-color:deeppink;

  transform:rotateZ(270deg)translateY(80px);

  }

  .circle10{

  background-color:lightyellow;

  transform:rotateZ(300deg)translateY(80px);

  }

  .circle11{

  background-color:lightgreen;

  transform:rotateZ(330deg)translateY(80px);

  }

  .circle12{

  background-color:lightslategrey;

  transform:rotateZ(360deg)translateY(80px);

  }

  </style>

  <body>

  <divclass="center-point"></div>

  <divclass="surround-box">

  <divclass="circlecircle1">1</div>

  <divclass="circlecircle2">2</div>

  <divclass="circlecircle3">3</div>

  <divclass="circlecircle4">4</div>

  <divclass="circlecircle5">5</div>

  <divclass="circlecircle6">6</div>

  <divclass="circlecircle7">7</div>

  <divclass="circlecircle8">8</div>

  <divclass="circlecircle9">9</div>

  <divclass="circlecircle10">10</div>

  <divclass="circlecircle11">11</div>

  <divclass="circlecircle12">12</div>

  </div>

  </body>


以上是“css3怎樣實現(xiàn)元素環(huán)繞中心點布局”這篇文章的所有內(nèi)容,感謝各位的閱讀!希望分享的內(nèi)容對大家有幫助,更多相關知識,歡迎關注億速云行業(yè)資訊頻道!

向AI問一下細節(jié)

免責聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉載和分享為主,文章觀點不代表本網(wǎng)站立場,如果涉及侵權請聯(lián)系站長郵箱:is@yisu.com進行舉報,并提供相關證據(jù),一經(jīng)查實,將立刻刪除涉嫌侵權內(nèi)容。

AI