首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何使Tailwind @layer组件响应?

如何使Tailwind @layer组件响应?
EN

Stack Overflow用户
提问于 2022-03-11 13:21:53
回答 1查看 286关注 0票数 1

如何在div中指定Tailwind @layer组件类的桌面版本?以下似乎不起作用,它显示移动版本独立于Chrome的断点:

代码语言:javascript
复制
    <button type="button" class="my-button md:my-button-desktop">Click here
    </button>

main.scss如下:

代码语言:javascript
复制
@tailwind base;
@tailwind components;
@tailwind utilities;

@layer components {
  .my-button {
    font-size: 1rem;
    font-weight: 100;
    line-height: 130%;
    color: theme("colors.white");
    background-color: theme("colors.btnDefault");
    border:solid;
    border-color: theme("colors.primaryColor100");
    border-width: 0.1rem;
    padding-top: 0.5rem;
    border-radius: 6px;
    padding-bottom: 1.5rem;
    text-align: center;
  }
.my-button-desktop {
    font-size: 1.2rem;
    font-weight: 400;
    line-height: 150%;
    color: theme("colors.white");
    background-color: theme("colors.btnDefault");
    border:solid;
    border-color: theme("colors.primaryColor100");
    border-width: 0.2rem;
    padding-top: 0.7rem;
    border-radius: 8px;
    padding-bottom: 2.5rem;
    text-align: left;
  }
EN

回答 1

Stack Overflow用户

发布于 2022-03-11 13:41:07

您可以在您的main.scss中使用默认的CSS @media规则,所以只需在最小宽度时修改它以更改..my按钮类:

代码语言:javascript
复制
@layer components {
  .my-button {
    font-size: 1rem;
    font-weight: 100;
    line-height: 130%;
    color: theme("colors.white");
    background-color: theme("colors.btnDefault");
    border: solid;
    border-color: theme("colors.primaryColor100");
    border-width: 0.1rem;
    padding-top: 0.5rem;
    border-radius: 6px;
    padding-bottom: 1.5rem;
    text-align: center;
  }

  @media (min-width: 768px) {
    .my-button {
      font-size: 1.2rem;
      font-weight: 400;
      line-height: 150%;
      color: theme("colors.white");
      background-color: theme("colors.btnDefault");
      border: solid;
      border-color: theme("colors.primaryColor100");
      border-width: 0.2rem;
      padding-top: 0.7rem;
      border-radius: 8px;
      padding-bottom: 2.5rem;
      text-align: left;
    }
  }
}

然后,您所要做的就是从按钮标记中删除md:my-button-desktop

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/71439192

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档