GH1995 / articles

blog
https://gh1995.github.io
2 stars 0 forks source link

css3 #65

Open GH1995 opened 4 years ago

GH1995 commented 4 years ago

用标签选择器绘制图1-2所示的3个圆

image

  <figure>
    <div></div>
    <div></div>
    <div></div>
  </figure>
figure {
  display: flex;
  justify-content: space-between;

  width: 350px;
  padding: 20px;

  background-color: silver;
}

div {
  width: 100px;
  height: 100px;
  border: 1px solid black;
  border-radius: 50%;
}
GH1995 commented 4 years ago

image

    <figure class="tree">
      <div class="branch">
        <span class="leaf"></span>
        <span class="leaf"></span>
        <span class="leaf"></span>
      </div>
      <div class="branch">
        <span class="leaf"></span>
        <span class="leaf"></span>
      </div>
    </figure>
.tree {
  display: flex;
  flex-direction: column;
  justify-content: space-around;

  width: 30px;
  height: 300px;
  border-radius: 5px;

  background-color: saddlebrown;
}

.tree .branch {
  display: flex;
  justify-content: flex-end;

  width: 160px;
  height: 20px;
  border-radius: 10px;
  transform: rotate(-30deg);

  background-color: peru;
}

.tree .branch .leaf {
  width: 40px;
  height: 40px;
  border-radius: 100% 0 100% 0;
  transform: translateY(-100%);

  background-color: green;
}
GH1995 commented 4 years ago

image


    <figure class="triangle">
      <div><span></span></div>
      <div><span></span><span></span></div>
      <div>
        <span></span>
        <span></span>
        <span></span>
      </div>
      <div>
        <span></span>
        <span></span>
        <span></span>
        <span></span>
      </div>
      <div>
        <span></span>
        <span></span>
        <span></span>
        <span></span>
        <span></span>
      </div>
      <div>
        <span></span>
        <span></span>
        <span></span>
        <span></span>
        <span></span>
        <span></span>
      </div>
    </figure>
.triangle {
    display: flex;
    flex-direction: column;
    align-items: center;

    width: 500px;

    div {
        display: flex;
        justify-content: space-between;

        height: 50px;
        margin: 5px;

        span {
            width: 50px;
            height: 50px;
            margin: 10px;
            border-radius: 50%;

            background-color: lightgreen;

            &:first-child, &:last-child {
                background-color: lightcoral;
            }
        }
    }
}