我想把圆形div叠加在一起

时间:2013-06-06 06:47:14

标签: css html

我有一个带有一些css的循环div,使其在mousover上扩展。我不知道如何开始用相同的中心点让另一个更大的圆圈坐在它后面。这可能会在第一个圆圈周围创建一个环。

e.g。

http://2.bp.blogspot.com/_HoDij8Z2tHY/TJzb854jDVI/AAAAAAAAEv4/dMzvpjkq8XI/s1600/concentric_circles1.jpg

图片示例

我不认为我解释得很好! :/抱歉!我需要单独的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) */

}

.circle1:hover
{
    top:-200px;
width:500px;
height:500px;

}

2 个答案:

答案 0 :(得分:1)

HTML:

<div class="circle"></div>

CSS:

.circle
{
    background-color: #aaf;
    width: 200px;
    height: 200px;
    border-radius: 100%;
    margin: 20px;
}

.circle:hover:after
{
    content: "";
    border-radius: 100%;
    width: 220px;
    height: 220px;
    border: 1px solid #aaf;
    display: block;
    position: absolute;
    margin: -10px;
}

示例:http://jsfiddle.net/6XF57/1/

注意:可能不适用于older browsers

答案 1 :(得分:0)

您也可以使用background-clip来做到这一点。

<强> CSS

div {
    height: 200px; width: 200px;
    border-radius: 120px;
    background-color: #40B3F7;
    -webkit-background-clip: content-box;
    -moz-background-clip: content-box;
    background-clip: content-box;
    padding: 20px;
    font: normal 30px/200px sans-serif;
    text-align: center;
    border: 1px solid transparent
}
div:hover {
    border: 1px solid #40B3F7;
}

<强> HTML

<div>Lorem</div>

Demo

相关问题