无法正确看到彩色条带。

huangapple go评论57阅读模式
英文:

not able to see color bands properly

问题

    .blob {
        height: 150px;
        width: 150px;
        border-radius: 58% 43% 33% 64%/50% 38% 53% 50%;
        background: transparent;
        box-shadow: inset 6px 33px 20px 0px #00FFFF, inset 20px 80px 15px 0px #Ffff00, 10px 20px 20px 0px #c9c9c9;
    }
    .blob:nth-child(1) {
        position: absolute;
        border-radius: 37% 54% 46% 46%;
        background: white;
        width: 50px;
        transform: rotate(-30deg);
        height: 15px;
        top: 20px;
        left: 40px;
    }
    .blob:nth-child(2) {
        position: absolute;
        border-radius: 50%;
        background: white;
        width: 10px;
        height: 10px;
        top: 60px;
        left: 20px;
    }
<div class="blob"></div>
<div class="blob"></div>
<div class="blob"></div>
<!--div class="blob"></div>
<div class="blob"></div-->
英文:

<!-- begin snippet: js hide: false console: true babel: false -->

<!-- language: lang-css -->

.blob {
            height: 150px;
            width: 150px;
            border-radius: 58% 43% 33% 64%/50% 38% 53% 50%;
            background: transparent;
            box-shadow: inset 6px 33px 20px 0px #00FFFF, inset 20px 80px 15px 0px #Ffff00, 10px 20px 20px 0px #c9c9c9 ;
        }
        .blob:nth-child(1)
			{
            position: absolute;
            border-radius: 37% 54% 46% 46%;
            background: white;
            width: 50px;
            transform: rotate(-30deg);
            height: 15px;
            top: 20px;
            left: 40px;
        }
         .blob:nth-child(2)
		{
            position: absolute;
            border-radius: 50%;
            background: white;
            width: 10px;
            height: 10px;
            top: 60px;
            left: 20px;
        }
/*
.blob:nth-child(3) {
  position: absolute;
  border-radius: 60%;
  background: aqua;
  width: 30px;
  height: 10px;
  top: 80px;
  left: 20px;
}

.blob:nth-child(4) {
  position: absolute;
  border-radius: 70%;
  background: white;
  width: 40px;
  height: 10px;
  top: 100px;
  left: 20px;
}

.blob:nth-child(5) {
  position: absolute;
  border-radius: 80%;
  background: white;
  width: 40px;
  height: 10px;
  top: 120px;
  left: 20px;
}

<!-- language: lang-html -->

&lt;div class=&quot;blob&quot;&gt;&lt;/div&gt;
&lt;div class=&quot;blob&quot;&gt;&lt;/div&gt;
&lt;div class=&quot;blob&quot;&gt;&lt;/div&gt;
&lt;!--div class=&quot;blob&quot;&gt;&lt;/div&gt;
&lt;div class=&quot;blob&quot;&gt;&lt;/div--&gt;

<!-- end snippet -->

color bands Aqua,yellow,white are displayed at the moment

Next I tried to add more colour bands via 3 more child elements(using the commented code in my html and css snippet) but then display gets clobbered up.

So I am unable to understand where I am going wrong in my geometries/concepts

credit:twitter @NanouuSymeon

答案1

得分: 1

你的主要形状和背景被应用于.blob元素。然而,你随后使用nth-child来覆盖所有这些样式以应用特定于元素的样式,而没有留下主要元素来显示原始背景和形状。

尝试将.blob元素包装在一个不同的元素中,将形状和背景应用于该元素。这样,你就不会让nth-child覆盖主要形状。

英文:

Your main shape with the background is being applied to .blob elements. However you are then using nth-child to overwrite all those styles with element-specific styles, and there is no main element left to show the original background and shape.

Try wrapping the .blob elements in a different element that will have the shape and background applied just to it. That way you will not have your nth-child override the main shape.

<!-- begin snippet: js hide: false console: true babel: false -->

<!-- language: lang-css -->

.shape {
  height: 150px;
  width: 150px;
  position: relative;
  border-radius: 58% 43% 33% 64%/50% 38% 53% 50%;
  background: transparent;
  box-shadow: inset 6px 33px 20px 0px #800080, inset 20px 80px 15px 0px #Ffff00, 10px 20px 20px 0px #c9c9c9;
}

.blob:nth-child(1) {
  position: absolute;
  border-radius: 37% 54% 46% 46%;
  background: white;
  width: 50px;
  transform: rotate(-30deg);
  height: 15px;
  top: 20px;
  left: 40px;
}

.blob:nth-child(2) {
  position: absolute;
  border-radius: 50%;
  background: white;
  width: 10px;
  height: 10px;
  top: 60px;
  left: 20px;
}

.blob:nth-child(3) {
  position: absolute;
  border-radius: 60%;
  background: aqua;
  width: 30px;
  height: 10px;
  top: 80px;
  left: 20px;
}

.blob:nth-child(4) {
  position: absolute;
  border-radius: 70%;
  background: white;
  width: 40px;
  height: 10px;
  top: 100px;
  left: 20px;
}

.blob:nth-child(5) {
  position: absolute;
  border-radius: 80%;
  background: white;
  width: 40px;
  height: 10px;
  top: 120px;
  left: 20px;
}

<!-- language: lang-html -->

&lt;div class=&quot;shape&quot;&gt;
  &lt;div class=&quot;blob&quot;&gt;&lt;/div&gt;
  &lt;div class=&quot;blob&quot;&gt;&lt;/div&gt;
  &lt;div class=&quot;blob&quot;&gt;&lt;/div&gt;
  &lt;div class=&quot;blob&quot;&gt;&lt;/div&gt;
  &lt;div class=&quot;blob&quot;&gt;&lt;/div&gt;
&lt;/div&gt;

<!-- end snippet -->

huangapple
  • 本文由 发表于 2023年5月17日 08:46:05
  • 转载请务必保留本文链接:https://go.coder-hub.com/76267908.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定