English 中文(简体)
Tailwind cstomfl in hsl with opcity is not work as used
原标题:Tailwind css custom color in hsl with opacity does not work as intended

我正在使用尾窗。 在我的<代码>全球cs上, 我有以下定义:

@layer base{
   --primary: 256, 92%, 63%, 1;
   --primary-foreground: 210 40% 98%;
}

在我的<代码>尾窗.config.js中,我有这一配置:

extend: {
   colors: {
     primary: {
          DEFAULT:  hsl(var(--primary)) ,
          foreground:  hsl(var(--primary-foreground)) ,
        },
   }
}

因此,我可以在我的构成部分中使用:

<div className="min-h-[380px] rounded-2xl border-2 border-dashed border-primary/75">
...
</div>

然而,产出实际上有所不同,与初等产出相比,产出并不相同,不太透明,而是看上去更白人。 然而,如果我只用黑色的黑体表示,它就行了:

<div className="min-h-[380px] rounded-2xl border-2 border-dashed border-[#784AF7]/75">
...
</div>

我不敢肯定为什么情况如此,但我认为我不理解何等工作。

如果这一职位在其他地方得到答复,那么我觉得可以自由提供,因为我没有真正找到与我的问题相近的东西。

问题回答

I don t think tailwind is relevant here. Your --primary is not even remotely the same as your --primary-foreground

在HSL(住所、涡轮机和光灯)中,如果你想要一个灯光的彩色,你就只能提高你的土地价值。 然而,你似乎想要减少不透明,因此,你只是把阿法价值作为第四参数(见四部分)。 虽然我只建议提高升值,但如果你控制实际彩色,而代谢价值则比较(见第五编)。

:root {
  --primary: 256, 92%, 63%, 1;
  --primary-foreground: 210 40% 98%;
  --reduced-op: 256, 92%, 63%, 0.75;
  --increased-light: 256, 92%, 75%, 1;
}

.blocks {
  display: flex;
  gap: 1rem;
}

[class*="block-"] {
  height: 5rem;
  width: 5rem;
  background-color: hotpink;
}

.block-1 {
  background-color: hsl(var(--primary));
}

.block-2 {
  background-color: hsl(var(--primary-foreground));
}

.block-3 {
  background-color: #784AF7;
}

.block-4 {
  background-color: hsl(var(--reduced-op));
}

.block-5 {
  background-color: hsl(var(--increased-light));
}
<section class="blocks">
  <div class="block-1"></div>
  <div class="block-2"></div>
  <div class="block-3"></div>
  <div class="block-4"></div>
  <div class="block-5"></div>
</section>




相关问题
CSS working only in Firefox

I am trying to create a search text-field like on the Apple website. The HTML looks like this: <div class="frm-search"> <div> <input class="btn" type="image" src="http://www....

jquery ui dialog opens only once

I have a button that opens a dialog when clicked. The dialog displays a div that was hidden After I close the dialog by clicking the X icon, the dialog can t be opened again.

Drop down background url in Safari Issue

selectBox.selectCSS { background: url(/Images/replacementSelectBackground.png) top left no-repeat height:auto; } I have an issue in Safari only where the image is not rendering on top ...

CSS specific for Safari

How do you target specifically safari in css with styles?

Aligning textarea in a form

Ive used the following css code to align my form elements: form { position:relative; } form input { position:absolute; left:11em; } However, the textarea element is not aligned correctly with the ...

Firefox background image horizontal centering oddity

I am building some basic HTML code for a CMS. One of the page-related options in the CMS is "background image" and "stretch page width / height to background image width / height." so that with large ...

CSS problem with page footer

I have defined my page footer in the css file as: #footer { position: absolute; height: 50px; text-align: center; background: #66CCCC; bottom: 0px; left: 0px; width: 100%; height: ...

热门标签