CSS,堆叠圈 [英] CSS, stacking circles

查看:36
本文介绍了CSS,堆叠圈的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在下面的代码中创建一些圆形的div.但是我希望它们堆叠在一起,所以我想要一个蓝色的圆圈(扩大)在当前红色圆圈之后,但与红色圆圈居中.红色的必须在顶部.

I want to make some circular divs like the one in my code below. However I want them stacked behind each other, so i would want a blue circle (that expands) behind the current red one, but centered the same as the red one. The red one needs to be on top.

这是我当前的代码:

#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) */

}

推荐答案

检查此jsFiddle: http://jsfiddle.net/ZTMxz/

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

}

这篇关于CSS,堆叠圈的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆