“box not getting shown” 可以翻译为 “框未显示”。

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

box not getting shown

问题

我正在尝试将我的气泡(blob)放入一个带有红色边框且大小为500像素的盒子中,但无法做到,请帮助我理解我的红色盒子在样式表中被放错了位置。

.box {
  border: 500px red;
}

.blob {
  height: 150px;
  width: 150px;
  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::before {
  content: 'abc';
  position: absolute;
  border-radius: 37% 54% 46% 46%;
  background: white;
  width: 50px;
  transform: rotate(-30deg);
  height: 15px;
  top: 20px;
  left: 20px;
}

.blob::after {
  content: 'def';
  position: absolute;
  border-radius: 50%;
  background: white;
  width: 10px;
  height: 10px;
  top: 60px;
  left: 20px;
}
<div class="box">
  <div class="blob"></div>
</div>

credit:@NanouuSymeon(twitter)

英文:

I am trying to place my bubble(blob) into a box with a red border and 500 pixels in size but unable to do so, please help me understand where my red box has been misplaced in the style sheet

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

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

.box {
  border: 500px red;
}

.blob {
  height: 150px;
  width: 150px;
  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::before {
  content: &#39;abc&#39;;
  position: absolute;
  border-radius: 37% 54% 46% 46%;
  background: white;
  width: 50px;
  transform: rotate(-30deg);
  height: 15px;
  top: 20px;
  left: 20px;
}

.blob::after {
  content: &#39;def&#39;;
  position: absolute;
  border-radius: 50%;
  background: white;
  width: 10px;
  height: 10px;
  top: 60px;
  left: 20px;
}

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

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

<!-- end snippet -->

credit:@NanouuSymeon(twitter)

答案1

得分: 3

您的边框属性缺少"solid",应该如下所示:

border: 500px solid red;

然而,如果边框这么厚,您的气泡会被包围。以下代码示例显示了一个边框为1px的情况:

.box {
  border: 1px solid red;
}

.blob {
  height: 150px;
  width: 150px;
  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::before {
  content: 'abc';
  position: absolute;
  border-radius: 37% 54% 46% 46%;
  background: white;
  width: 50px;
  transform: rotate(-30deg);
  height: 15px;
  top: 20px;
  left: 20px;
}

.blob::after {
  content: 'def';
  position: absolute;
  border-radius: 50%;
  background: white;
  width: 10px;
  height: 10px;
  top: 60px;
  left: 20px;
}

HTML部分:

<div class="box">
  <div class="blob"></div>
</div>
英文:

Your border property is missing solid like so:

border: 500px solid red;

However, with a border this thick, your bubble is engulfed. The below snippet shows with a border of 1px

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

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

.box {
  border: 1px solid red;
}

.blob {
  height: 150px;
  width: 150px;
  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::before {
  content: &#39;abc&#39;;
  position: absolute;
  border-radius: 37% 54% 46% 46%;
  background: white;
  width: 50px;
  transform: rotate(-30deg);
  height: 15px;
  top: 20px;
  left: 20px;
}

.blob::after {
  content: &#39;def&#39;;
  position: absolute;
  border-radius: 50%;
  background: white;
  width: 10px;
  height: 10px;
  top: 60px;
  left: 20px;
}

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

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

<!-- end snippet -->

答案2

得分: 2

以下是您要翻译的内容:

"Your question is a bit unclear: "box with 500px size": 500px what – width, height? In my snippet below I set it to 500px width and height and defined the red border solid and 1px wide. Adopt that to your needs...

To center the contents inside it, you can add flex-settings as done below. In that case, also add position: relative; to .blob to make it the position reference for your absolutely positioned pseudo-elements.

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

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

.box {
  border: 1px solid red;
  height: 500px;
  width: 500px;
  display: flex;
  justify-content: center;
  align-items: center;
}

.blob {
  height: 150px;
  width: 150px;
  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;
  position: relative;
}

.blob::before {
  content: &#39;abc&#39;;
  position: absolute;
  border-radius: 37% 54% 46% 46%;
  background: white;
  width: 50px;
  transform: rotate(-30deg);
  height: 15px;
  top: 20px;
  left: 20px;
}

.blob::after {
  content: &#39;def&#39;;
  position: absolute;
  border-radius: 50%;
  background: white;
  width: 10px;
  height: 10px;
  top: 60px;
  left: 20px;
}

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

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

<!-- end snippet -->"

英文:

Your question is a bit unclear: "box with 500px size": 500px what – width, height? In my snippet below I set it to 500px width and height and defined the red border solid and 1px wide. Adopt that to your needs...

To center the contents inside it, you can add flex-settings as done below. In that case, also add position: relative; to .blob to make it the position reference for your absolutely positioned pseudo-elements.

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

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

.box {
  border: 1px solid red;
  height: 500px;
  width: 500px;
  display: flex;
  justify-content: center;
  align-items: center;
}

.blob {
  height: 150px;
  width: 150px;
  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;
  position: relative;
}

.blob::before {
  content: &#39;abc&#39;;
  position: absolute;
  border-radius: 37% 54% 46% 46%;
  background: white;
  width: 50px;
  transform: rotate(-30deg);
  height: 15px;
  top: 20px;
  left: 20px;
}

.blob::after {
  content: &#39;def&#39;;
  position: absolute;
  border-radius: 50%;
  background: white;
  width: 10px;
  height: 10px;
  top: 60px;
  left: 20px;
}

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

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

<!-- end snippet -->

huangapple
  • 本文由 发表于 2023年5月14日 21:54:42
  • 转载请务必保留本文链接:https://go.coder-hub.com/76247833.html
匿名

发表评论

匿名网友

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

确定