【问题标题】:Divide Circle into three parts using CSS3使用 CSS3 将圆分成三部分
【发布时间】:2016-07-29 20:27:01
【问题描述】:

我正在做圆圈我想把圆圈分成 3 部分,如附图

每个部分都是可点击的,我使用的是 HTML5、CSS3 和 jQuery,是否可以将圆分成 3 个部分?

.circle {
  position: relative;
  border: 1px solid black;
  padding: 0;
  margin: 1em auto;
  width: 430px;
  height: 430px;
  border-radius: 50%;
  list-style: none;
  overflow: hidden;
}
li {
  overflow: hidden;
  position: absolute;
  top: 0;
  right: 0;
  width: 50%;
  height: 50%;
  transform-origin: 0% 100%;
}
.text {
  position: absolute;
  left: -100%;
  width: 200%;
  height: 200%;
  text-align: center;
  transform: skewY(-60deg) rotate(15deg);
  padding-top: 20px;
}
li:first-child {
  transform: rotate(0deg) skewY(30deg);
}
li:nth-child(2) {
  transform: rotate(120deg) skewY(30deg);
}
li:nth-child(3) {
  transform: rotate(240deg) skewY(30deg);
}
li:first-child .text {
  background: green;
}
li:nth-child(2) .text {
  background: tomato;
}
li:nth-child(3) .text {
  background: aqua;
}
<ul class="circle">
  <li>
    <div class="text">1</div>
  </li>
  <li>
    <div class="text">2</div>
  </li>
  <li>
    <div class="text">3</div>
  </li>
</ul>

【问题讨论】:

  • 你能发布 jQuery/javascript 吗?将使回答变得容易得多。谢谢!
  • 对不起老兄,html5只有css3..@AgataB
  • 不知道 svg,你能展示或如何在我的场景中使用 svg
  • 你可以看看这支笔,看看它是否有帮助pen1pen2

标签: jquery html css


【解决方案1】:

希望这个 sn-p 对您有所帮助。也许尝试使用 jQuery 悬停。

.circle-outer {
  position: relative;
  border: 1px solid black;
  padding: 0;
  margin: 1em auto;
  width: 430px;
  height: 430px;
  border-radius: 50%;
  list-style: none;
  overflow: hidden;
}
.circle {
  position: absolute;
  border: 1px solid black;
  padding: 0;
  margin: 1em auto;
  width: 580px;
  height: 580px;
  border-radius: 50%;
  list-style: none;
  overflow: hidden;
  left: -70px;
  top: -95px;
}
li {
  
}
li .background {
  overflow: hidden;
  position: absolute;
  top: 0;
  right: 0;
  width: 50%;
  height: 50%;
  transform-origin: 0% 100%;
}
.content {
  position: absolute;
  z-index: 30;
  text-align: center;
  width: 200px;
}
.content .icon {
  font-size: 80px;
  color: #000;
}
.content.first {
  left: 15%;
  top: 30%;
}
.content.second {
  right: 15%;
  top: 30%
}
.content.third {
  bottom: 15%;
  left: 32%
}
li:first-child .background {
  transform: rotate(0deg) skewY(30deg);
}
li:nth-child(2) .background {
  transform: rotate(120deg) skewY(30deg);
}
li:nth-child(3) .background {
  transform: rotate(240deg) skewY(30deg);
}
li:first-child .background {
  background: green;
}
li:nth-child(2) .background {
  background: tomato;
}
li:nth-child(3) .background {
  background: aqua;
}
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.6.3/css/font-awesome.css">
<div class="circle-outer">

  <ul class="circle">
    <li>
      <a href="#">
        <div class="content first">
          <div class="icon">
            <div class="fa fa-search"></div>
          </div>
          <p>Text</p>
        </div>
        <div class="background"></div>
      </a>
    </li>
    <li>
      <a href="#">
        <div class="content second">
          <div class="icon">
            <div class="fa fa-search"></div>
          </div>
          <p>Text</p>
        </div>
        <div class="background"></div>
      </a>
    </li>
        <li>
      <a href="#">
        <div class="content third">
          <div class="icon">
            <div class="fa fa-search"></div>
          </div>
          <p>Text</p>
        </div>
        <div class="background"></div>
      </a>
    </li>
  </ul>
</div>

【讨论】:

  • 完美 @MarcosPérezGude,Safari 中唯一的问题,我在所有课程中都添加了 -webkit- 但没有运气
【解决方案2】:

检查我的答案:

.circle {
  position: relative;
  border: 1px solid black;
  padding: 0;
  margin: 1em auto;
  width: 430px;
  height: 430px;
  border-radius: 50%;
  list-style: none;
  overflow: hidden;
}
li {
  overflow: hidden;
  position: absolute;
  top: -20%;
  right: -20%;
  width: 70%;
  height: 70%;
  transform-origin: 0% 100%;
}
.text {
  position: absolute;
  left: -100%;
  width: 200%;
  height: 200%;
  text-align: center;
  transform: skewY(-60deg) rotate(15deg);
  padding-top: 20px;
}
li:first-child {
  transform: rotate(0deg) skewY(30deg);
}
li:nth-child(2) {
  transform: rotate(120deg) skewY(30deg);
}
li:nth-child(3) {
  transform: rotate(240deg) skewY(30deg);
}
li:first-child .text {
  background: green;
}
li:nth-child(2) .text {
  background: tomato;
}
li:nth-child(3) .text {
  background: aqua;
}
<ul class="circle">
  <li>
    <div class="text">1</div>
  </li>
  <li>
    <div class="text">2</div>
  </li>
  <li>
    <div class="text">3</div>
  </li>
</ul>

【讨论】:

  • 感谢@eronax59 的支持,效果很好!唯一的问题是它在 Safari 中表现不佳
猜你喜欢
  • 2012-12-20
  • 1970-01-01
  • 2021-09-13
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2012-09-17
  • 2012-10-15
  • 2023-04-06
相关资源
最近更新 更多