在div

时间:2017-05-11 01:54:12

标签: html css dom

我有一个看起来像一个大广场的div但是我想在div的顶部添加一个小圆圈(保持风格)里面有一个图标(我的意思是类似Font Awesome)所以人们会知道什么它的内容类别。

我怎么能用css做到这一点?

谢谢

.le_quiz {
  position: relative;
  width: 350px;
  background-color: white;
  height: 400px;
  margin-top: 45px;
  border-bottom: 1px solid lightgrey;
  box-shadow: 0px 2px #40c8d6;
  box-shadow: 0 4px 8px 0 rgba(0, 0, 0, 0.01), 0 2px 5px 0 rgba(0, 0, 0, 0.19);
}

.le_quiz .post-title {
  position: absolute;
  top: 60%;
  left: 2%;
  font-size: 22px;
  color: #404040;
}

.le_quiz .postbody {
  margin-top: 40px;
  font-size: 22px;
}

.le_quiz .postbody a:visited {
  margin-top: 40px;
  font-size: 22px;
  color:#404040;
}
.le_quiz .cta {
  position: absolute;
  top: 90%;
  left: 15px;
  font-weight: bold;
  font-size: 14px;
  color:#38C8D6;
}
.le_quiz .cta:visited {
  color:#38C8D6;
}
<div class="le_quiz">
</div>

这就是我想要的:Circle

2 个答案:

答案 0 :(得分:1)

您可以使用2个伪元素。一个将圆圈放在上面,另一个覆盖圆圈的下半部分。

&#13;
&#13;
.le_quiz {
  position: relative;
  width: 350px;
  background-color: white;
  height: 400px;
  margin-top: 60px;
  border-bottom: 1px solid lightgrey;
  box-shadow: 0px 2px #40c8d6;
  box-shadow: 0 4px 8px 0 rgba(0, 0, 0, 0.01), 0 2px 5px 0 rgba(0, 0, 0, 0.19);
}

.le_quiz .post-title {
  position: absolute;
  top: 60%;
  left: 2%;
  font-size: 22px;
  color: #404040;
}

.le_quiz .postbody {
  margin-top: 40px;
  font-size: 22px;
}

.le_quiz .postbody a:visited {
  margin-top: 40px;
  font-size: 22px;
  color:#404040;
}
.le_quiz .cta {
  position: absolute;
  top: 90%;
  left: 15px;
  font-weight: bold;
  font-size: 14px;
  color:#38C8D6;
}
.le_quiz .cta:visited {
  color:#38C8D6;
}

.le_quiz:before, .le_quiz:after {
  content: '';
  position: absolute;
  background: #fff;
  top: 0;
}

.le_quiz:before {
    left: 0;
    right: 0;
    height: 60px;
    z-index: 2;
}

.le_quiz:after {
    left: 50%;
    transform: translate(-50%,-50%);
    box-shadow: 0 4px 8px 0 rgba(0, 0, 0, 0.01), 0 2px 5px 0 rgba(0, 0, 0, 0.19);
    z-index: 1;
    width: 100px;
    height: 100px;
    border-radius: 50%;
}
&#13;
<div class="le_quiz">
</div>
&#13;
&#13;
&#13;

答案 1 :(得分:0)

您可以添加另一个div并将boder-radius设置为50%以使其成为圆圈。

&#13;
&#13;
.le_quiz, .circle {
  position: relative;
  width: 350px;
  background-color: white;
  height: 400px;
  margin-top: 45px;
  border-bottom: 1px solid lightgrey;
  box-shadow: 0px 2px #40c8d6;
  box-shadow: 0 4px 8px 0 rgba(0, 0, 0, 0.01), 0 2px 5px 0 rgba(0, 0, 0, 0.19);
}

.le_quiz .post-title {
  position: absolute;
  top: 60%;
  left: 2%;
  font-size: 22px;
  color: #404040;
}

.le_quiz .postbody {
  margin-top: 40px;
  font-size: 22px;
}

.le_quiz .postbody a:visited {
  margin-top: 40px;
  font-size: 22px;
  color:#404040;
}
.le_quiz .cta {
  position: absolute;
  top: 90%;
  left: 15px;
  font-weight: bold;
  font-size: 14px;
  color:#38C8D6;
}
.le_quiz .cta:visited {
  color:#38C8D6;
}
.circle {
  width:100px;
  height:100px;
  border-radius:50%;
  top: 100px;
  left: 120px;
}
&#13;
<div class="circle"></div>
<div class="le_quiz">
</div>
&#13;
&#13;
&#13;