2

我想制作一些圆形 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) */

}
4

2 回答 2

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%;

}
于 2013-06-06T17:46:24.080 回答
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: "";
}
于 2013-06-06T18:01:43.150 回答