如何使用HTML和CSS创建卡片的背景框架。

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

how to create this background frame to the card using html and css

问题

以下是翻译好的部分:

.card {
  background-color: var(--background);
  display: block;
  width: 300px;
  min-height: 90px;
  cursor: pointer;
  padding: 15px;
  margin: calc(50vh - 30px) auto 0 auto;
  border: 3px solid var(--primary);
  box-shadow: 10px -10px 0 -3px var(--background), 10px -10px var(--green);
}

如果您需要任何其他帮助,请随时告诉我。

英文:

enter image description here how to create this card having this brown and yellow colored frame

thanks in advance

i tried with css border with this code but it is only creating brown part, i am not able to create yellow part of the frame

.card {
  background-color: var(--background);
  display: block;
  width: 300px;
  min-height: 90px;
  cursor: pointer;
  padding: 15px;
  margin: calc(50vh - 30px) auto 0 auto;
  border: 3px solid var(--primary);
  box-shadow: 10px -10px 0 -3px var(--background), 10px -10px var(--green);
}

答案1

得分: 2

这样可以吗?

你可以在 before 和 after 中玩数值,实际上是在周围 5px。

.card {
  position: relative;
  background-color: grey;
  display: block;
  width: 300px;
  min-height: 90px;
  cursor: pointer;
  padding: 15px;
  margin: calc(50vh - 30px) auto 0 auto;
}

.card::before {
  content: '';
  position: absolute;
  left: -5px;
  top: -5px;
  width: calc(100% - 25px);
  height: calc(100% - 10px);
  border-top: 5px solid brown;
  border-left: 5px solid brown;
}

.card::after {
  content: '';
  position: absolute;
  top: -5px;
  right: 10px;
  height: 5px;
  width: 25px;
  background-color: orange;
}
<div class="card">
</div>
英文:

is it ok for you?

you can play with values in before and after, actually it's 5px around.

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

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

.card {
  position: relative;
  background-color: grey;
  display: block;
  width: 300px;
  min-height: 90px;
  cursor: pointer;
  padding: 15px;
  margin: calc(50vh - 30px) auto 0 auto;
}

.card::before {
  content: &#39;&#39;;
  position: absolute;
  left: -5px;
  top: -5px;
  width: calc(100% - 25px);
  height: calc(100% - 10px);
  border-top: 5px solid brown;
  border-left: 5px solid brown;
}

.card::after {
  content: &#39;&#39;;
  position: absolute;
  top: -5px;
  right: 10px;
  height: 5px;
  width: 25px;
  background-color: orange;
}

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

&lt;div class=&quot;card&quot;&gt;
&lt;/div&gt;

<!-- end snippet -->

huangapple
  • 本文由 发表于 2023年2月19日 18:31:23
  • 转载请务必保留本文链接:https://go.coder-hub.com/75499476.html
匿名

发表评论

匿名网友

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

确定