我怎样才能从左向右滑动这个 React 抽屉

发布于 2025-01-15 05:42:46 字数 824 浏览 3 评论 0原文

我在React中做了一个抽屉,这是我从互联网上得到的

问题是它总是从右到左滑动,而且我不知道如何让它从左到右滑动

抽屉的CSS代码是:

html {
  height: 100%;
}
body {
  margin: 0;
  padding: 0;
  height: 100%;
}
.side-drawer {
  position: fixed;
  height: 100%;
  background: black;
  color: white;
  top: 0;
  right: 0;
  width: 40%;
  z-index: 200;
  box-shadow: 1px 0px 7px rgba(0, 0, 0, 0.5);
  transform: translateX(100%);
  transition: transform 0.3s ease-out;
}
.side-drawer.open {
  transform: translateX(0);
}

我不知道不知道为什么它会这样滑动,我猜这与转换/变换有关

如何让它从左向右滑动?

我为它创建了一个沙箱

编辑 React 侧抽屉

预先感谢

拉斐尔

I made a drawer in React, that I got from the internet

The problem is that it always slides from right to left, and I don't know to to make it slide from left to right

The CSS code for the drawer is:

html {
  height: 100%;
}
body {
  margin: 0;
  padding: 0;
  height: 100%;
}
.side-drawer {
  position: fixed;
  height: 100%;
  background: black;
  color: white;
  top: 0;
  right: 0;
  width: 40%;
  z-index: 200;
  box-shadow: 1px 0px 7px rgba(0, 0, 0, 0.5);
  transform: translateX(100%);
  transition: transform 0.3s ease-out;
}
.side-drawer.open {
  transform: translateX(0);
}

I don't know why it slides the way it does, I guess it is related to transition/transform

How can I make it slide from left to right?

I made a sandbox for it

Edit React Side Drawer

Thanks in advance

Rafael

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

暮年 2025-01-22 05:42:46

我得到了它!

这是我的新 CSS:

.side-drawer {
  position: fixed;
  height: 100%;
  background: black;
  color: white;
  top: 0;
  right: 100%; /* changed it */
  width: 40%;
  z-index: 200;
  box-shadow: 1px 0px 7px rgba(0, 0, 0, 0.5);
  transform: translateX(0); /* changed it */
  transition: transform 0.3s ease-out;
}
.side-drawer.open {
  transform: translateX(100%); /* changed it */
}

I got it!

this is my new CSS:

.side-drawer {
  position: fixed;
  height: 100%;
  background: black;
  color: white;
  top: 0;
  right: 100%; /* changed it */
  width: 40%;
  z-index: 200;
  box-shadow: 1px 0px 7px rgba(0, 0, 0, 0.5);
  transform: translateX(0); /* changed it */
  transition: transform 0.3s ease-out;
}
.side-drawer.open {
  transform: translateX(100%); /* changed it */
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文