CSS,堆叠圈子

时间:2013-06-06 16:33:14

标签: css

我想在下面的代码中创建一些循环div。但是我希望它们堆叠在一起,所以我想要一个蓝色的圆圈(扩展)在当前的红色圆圈后面,但是中心与红色圆圈相同。红色的需要在顶部。

这是我目前的代码:

#circles
{
margin-right:auto;
margin-left:auto;
width:800px;
height:800px;
alignment-adjust:central;
}

.circle1
{position:relative;

margin-top:50%;
margin-right:auto;
margin-left:auto;
width:100px;
height:100px;
border-radius:50%;
background: #ff3019; /* Old browsers */
background: -moz-linear-gradient(top, #ff3019 0%, #cf0404 100%); /* FF3.6+ */
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#ff3019), color-stop(100%,#cf0404)); /* Chrome,Safari4+ */
background: -webkit-linear-gradient(top, #ff3019 0%,#cf0404 100%); /* Chrome10+,Safari5.1+ */
background: -o-linear-gradient(top, #ff3019 0%,#cf0404 100%); /* Opera 11.10+ */
background: -ms-linear-gradient(top, #ff3019 0%,#cf0404 100%); /* IE10+ */
background: linear-gradient(to bottom, #ff3019 0%,#cf0404 100%); /* W3C */  

transition:1s;
-moz-transition: 1s; /* Firefox 4 */
-webkit-transition: 1s; /* Safari and Chrome */
-o-transition: 1s; /* Opera */
-ms-transition: 1s; /* IE9 (maybe) */

}

2 个答案:

答案 0 :(得分:0)

检查这个jsFiddle:http://jsfiddle.net/ZTMxz/

这是你在找什么?

以下是代码:

#circles
{
margin-right:auto;
margin-left:auto;
width:800px;
height:800px;
alignment-adjust:central;
}

.circle1
{position:relative;

margin-top:50%;
margin-right:auto;
margin-left:auto;
width:100px;
height:100px;
border-radius:50%;
background: #ff3019; /* Old browsers */
background: -moz-linear-gradient(top, #ff3019 0%, #cf0404 100%); /* FF3.6+ */
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#ff3019), color-stop(100%,#cf0404)); /* Chrome,Safari4+ */
background: -webkit-linear-gradient(top, #ff3019 0%,#cf0404 100%); /* Chrome10+,Safari5.1+ */
background: -o-linear-gradient(top, #ff3019 0%,#cf0404 100%); /* Opera 11.10+ */
background: -ms-linear-gradient(top, #ff3019 0%,#cf0404 100%); /* IE10+ */
background: linear-gradient(to bottom, #ff3019 0%,#cf0404 100%); /* W3C */  

transition:1s;
-moz-transition: 1s; /* Firefox 4 */
-webkit-transition: 1s; /* Safari and Chrome */
-o-transition: 1s; /* Opera */
-ms-transition: 1s; /* IE9 (maybe) */
z-index: 2;

}
.circle2
{position:relative;

margin-top:50%;
margin-right:auto;
margin-left:auto;
width:140px;
height:140px;
border-radius:50%;
background: #ff3019; /* Old browsers */
background: -moz-linear-gradient(top,  #b8d8f2 0%, #92bde0 100%); /* FF3.6+ */
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%, #b8c7f2), color-stop(100%,#92bde0)); /* Chrome,Safari4+ */
background: -webkit-linear-gradient(top,  #b8d8f2 0%,#92bde0 100%); /* Chrome10+,Safari5.1+ */
background: -o-linear-gradient(top,  #b8d8f2 0%,#92bde0 100%); /* Opera 11.10+ */
background: -ms-linear-gradient(top,  #b8d8f2 0%,#92bde0 100%); /* IE10+ */
background: linear-gradient(to bottom,  #b8d8f2 0%,#92bde0 100%); /* W3C */  

transition:1s;
-moz-transition: 1s; /* Firefox 4 */
-webkit-transition: 1s; /* Safari and Chrome */
-o-transition: 1s; /* Opera */
-ms-transition: 1s; /* IE9 (maybe) */
z-index: 1;
margin-top: -15%;

}

答案 1 :(得分:0)

也许这样的事情会更容易一些:

.circle {
  width: 140px;
  height: 140px;
  border-radius: 50%;
  background: blue;
}

.circle:before {
  position: relative;
  top: 20px;
  left: 20px;
  display: block;
  width: 100px;
  height: 100px;
  border-radius: 50%;
  background: red;
  content: "";
}