2017-07-07 169 views
-3

我想使用CSS来设计<div>,如下图所示。我没有得到任何线索。请提供此设计的想法。如何在div上放置div?

Designed image

+2

我们不是免费的代码编写的服务。先尝试一下并展示你的研究成果。 – Xufox

+2

如果你想要这个想法,那么这里是:在元素上创建需要使用'border-radius:50%'的圆。第一个元素是大圆圈,周围的“发光”可以用大圆圈的':after'伪元素进行绝对定位。比你有4个更小的圆圈,你可以使用绝对定位的':before'伪元素使它们成为箭头。 –

+0

我将来会改进我的问题.. @Xufox –

回答

0

好了,不带箭头的,但我认为这是一个良好的开端学习。

编辑:增加了一些箭头。

#bigGrayOneBox { 
 
    position: absolute; 
 
} 
 

 
#bigGrayOne { 
 
    width: 100px; 
 
    height: 100px; 
 
    background-color: #E9E9E9; 
 
    border-radius: 100%; 
 
    border: 10px solid white; 
 
    position: relative; 
 
    top: 100px; 
 
} 
 

 
#bigGrayOne:after { 
 
    border-radius: 100%; 
 
    position: absolute; 
 
    width: 118px; 
 
    height: 118px; 
 
    border: 1px solid #E9E9E9; 
 
    content: ""; 
 
    z-index: 1; 
 
    top: -10px; 
 
    left: -10px; 
 
} 
 

 
#yellow, 
 
#green, 
 
#purple, 
 
#blue { 
 
    width: 50px; 
 
    height: 50px; 
 
    border-radius: 100%; 
 
    position: absolute; 
 
} 
 

 
#yellow { 
 
    background-color: #E2A213; 
 
    top: 35px; 
 
    left: 100px; 
 
} 
 

 
#yellow::before { 
 
    content: ''; 
 
    left: -18px; 
 
    top: 69px; 
 
    transform: rotate(-58deg); 
 
    width: 30px; 
 
    height: 5px; 
 
    display: block; 
 
    background-color: #E2A213; 
 
    position: absolute; 
 
    z-index: 1; 
 
} 
 

 
#yellow::after { 
 
    content: ""; 
 
    transform: rotate(28deg); 
 
    border-color: transparent transparent #E2A213 transparent; 
 
    display: block; 
 
    border-width: 10px; 
 
    border-style: solid; 
 
    width: 0px; 
 
    position: absolute; 
 
    top: 43px; 
 
    left: -2px; 
 
} 
 

 
#green { 
 
    background-color: #00A19A; 
 
    top: 100px; 
 
    left: 160px; 
 
} 
 

 
#green::before { 
 
    content: ''; 
 
    left: -43px; 
 
    top: 40px; 
 
    transform: rotate(-18deg); 
 
    width: 30px; 
 
    height: 5px; 
 
    display: block; 
 
    background-color: #00A19A; 
 
    position: absolute; 
 
    z-index: 1; 
 
} 
 

 
#green::after { 
 
    content: ""; 
 
    transform: rotate(73deg); 
 
    border-color: transparent transparent #00A19A transparent; 
 
    display: block; 
 
    border-width: 10px; 
 
    border-style: solid; 
 
    width: 0px; 
 
    position: absolute; 
 
    top: 25px; 
 
    left: -15px; 
 
} 
 

 
#purple { 
 
    background-color: #D63080; 
 
    top: 180px; 
 
    left: 160px; 
 
} 
 

 
#purple::before { 
 
    content: ''; 
 
    left: -41px; 
 
    top: 5px; 
 
    transform: rotate(19deg); 
 
    width: 30px; 
 
    height: 5px; 
 
    display: block; 
 
    background-color: #D63080; 
 
    position: absolute; 
 
    z-index: 1; 
 
} 
 

 
#purple::after { 
 
    content: ""; 
 
    transform: rotate(107deg); 
 
    border-color: transparent transparent #D63080 transparent; 
 
    display: block; 
 
    border-width: 10px; 
 
    border-style: solid; 
 
    width: 0px; 
 
    position: absolute; 
 
    top: 6px; 
 
    left: -13px; 
 
} 
 

 
#blue { 
 
    background-color: #173DC6; 
 
    top: 245px; 
 
    left: 105px; 
 
} 
 

 
#blue::before { 
 
    content: ''; 
 
    left: -16px; 
 
    top: -22px; 
 
    transform: rotate(61deg); 
 
    width: 30px; 
 
    height: 5px; 
 
    display: block; 
 
    background-color: #173DC6; 
 
    position: absolute; 
 
    z-index: 1; 
 
} 
 

 
#blue::after { 
 
    content: ""; 
 
    transform: rotate(148deg); 
 
    border-color: transparent transparent #173DC6 transparent; 
 
    display: block; 
 
    border-width: 10px; 
 
    border-style: solid; 
 
    width: 0px; 
 
    position: absolute; 
 
    top: -8px; 
 
    left: 1px; 
 
}
<div id="bigGrayOneBox"> 
 
    <div id="bigGrayOne"> 
 
    </div> 
 
</div> 
 
<div id="yellow"> 
 
</div> 
 
<div id="green"> 
 
</div> 
 
<div id="purple"> 
 
</div> 
 
<div id="blue"> 
 
</div>

+0

谢谢帕特里克。但我已经尝试过,像大灰色的那个不是绝对的定位。 –

+0

@JeevaJsb我编辑它,现在位置:absoulte,它有一些箭头。 –

+0

感谢您的帮助。 –

1

为了让你和你的想法,即使你应该自己尝试过的东西。

什么仍然有许多工作要做设置所有箭头的志愿服务岗位...

.wrap { 
 
    position: relative; 
 
} 
 

 
.wrap > div { 
 
    position: absolute; 
 
    width: 90px; 
 
    height: 90px; 
 
    background-color: #AFAFAF; 
 
    border-radius: 50%; 
 
} 
 

 
.wrap > div.gray { 
 
    position: absolute; 
 
    top: 100px; 
 
    left: 50px; 
 
    width: 200px; 
 
    height: 200px; 
 
    background-color: #CFCFCF; 
 
} 
 

 
.wrap > div.gray:before { 
 
    position: relative; 
 
    top: -20px; 
 
    left: -20px; 
 
    content: ''; 
 
    display: block; 
 
    width: 200px; 
 
    height: 200px; 
 
    border-radius: 50%; 
 
    z-index: -1; 
 
    border: solid 1px #CFCFCF; 
 
    padding: 20px; 
 
} 
 

 
.wrap > div.orange { 
 
    background-color: orange; 
 
    top: 0px; 
 
    left: 200px; 
 
} 
 
.wrap > div.green { 
 
    background-color: green; 
 
    top: 80px; 
 
    left: 270px; 
 
} 
 
.wrap > div.purple { 
 
    background-color: purple; 
 
    top: 180px; 
 
    left: 290px; 
 
} 
 
.wrap > div.blue { 
 
    background-color: blue; 
 
    top: 290px; 
 
    left: 290px; 
 
} 
 

 

 
/* arrows */ 
 
.wrap > div:not(.gray):before { 
 
    position: absolute; 
 
    left: -40px; 
 
    top: 60%; 
 
    content: ''; 
 
    display: inline-block; 
 
    width: 30px; 
 
    height: 3px; 
 
    background-color: inherit; 
 
} 
 
.wrap > div:not(.gray):after { 
 
    position: absolute; 
 
    content: ''; 
 
    display: block; 
 
    width: 0; 
 
    height: 0; 
 
    border-style: solid; 
 
    border-width: 0 10px 10px 10px; 
 
    border-color: transparent transparent fuchsia transparent; 
 
} 
 

 
.wrap > div.orange:before { 
 
    left: -40px; 
 
    top: 100%; 
 
    transform: rotate(-40deg); 
 
} 
 
.wrap > div.orange:after { 
 
    left: -20px; 
 
    top: 75px; 
 
    transform: rotate(44deg); 
 
    border-color: transparent transparent orange transparent; 
 
} 
 

 

 
.wrap > div.green:before { 
 
    /* needs position and transform */ 
 
    /* see .wrap > div.orange:before {} */ 
 
} 
 
.wrap > div.green:after { 
 
    /* needs position, transform and border-color */ 
 
    /* see .wrap > div.orange:after {} */ 
 
} 
 

 
.wrap > div.purple:before { 
 
    /* needs position and transform */ 
 
    /* see .wrap > div.orange:before {} */ 
 
} 
 
.wrap > div.purple:after { 
 
    /* needs position, transform and border-color */ 
 
    /* see .wrap > div.orange:after {} */ 
 
} 
 

 
.wrap > div.blue:before { 
 
    /* needs position and transform */ 
 
    /* see .wrap > div.orange:before {} */ 
 
} 
 
.wrap > div.blue:after { 
 
    /* needs position, transform and border-color */ 
 
    /* see .wrap > div.orange:after {} */ 
 
}
<div class="wrap"> 
 
    <div class="gray"></div> 
 
    <div class="orange"></div> 
 
    <div class="green"></div> 
 
    <div class="purple"></div> 
 
    <div class="blue"></div> 
 
</div>

+1

谢谢...... –