So i have component that i try to make it responsive, but when it comes to media below md: it not working at all and i have some problem on turning the view into what i want Here is the look on the web view: enter image description here

and here is the problem : enter image description here

is that posible to make the button into this when it comes to phone view? enter image description here

以下是我的try :

const CardCalculation = () => {
  return (
    

    <div className="ml-2">
  <div className="mx-auto lg:flex lg:items-center lg:justify-between">
    <h2 className="tracking-tight text-gray-900 sm:text-xl">
      <div className="gap-2">
        <div className="w-[120px] h-[110px] absolute bg-[#d9d9d9] lg:mb-10"></div>
        <div className="text-xl ml-32 text-left text-[#e44]">
          Mie Goleng
        </div>
        <div className="ml-32 text-left text-[#b4b4b4]">Plant K103.</div>
        <div className="ml-32 text-left text-[#b4b4b4]">500.02 UOG.</div>
      </div>
    </h2>
    <div className="mt-4 flex lg:mt-0 lg:flex-shrink-0 md:mt-4 sm:mt-8">
      <div>
        <div className="rounded-md mb-2 shadow">
          <a
            href="#"
            className="inline-flex items-center justify-center rounded-md border border-transparent bg-indigo-600 px-5 py-3 text-base font-medium text-white hover:bg-indigo-700"
          >
            Get started
          </a>
        </div>
        <div className="rounded-md shadow">
          <a
            href="#"
            className="inline-flex items-center justify-center rounded-md border border-transparent bg-indigo-600 px-5 py-3 text-base font-medium text-indigo-600 hover:bg-indigo-50"
          >
            Learn more
          </a>
        </div>
      </div>
    </div>
  </div>
</div>
  );
};
export default CardCalculation;

有人能向我解释一下为什么它对屏幕没有react 吗?当涉及到手机查看时,是否可以将按钮转换为水平,如下所示?

推荐答案

Use the following code:

<div class="p-2">
  <div class="flex flex-col md:flex-row md:justify-between">
    <div class="flex gap-4">
      <div name="grey window" class="h-[110px] w-[120px] bg-[#d9d9d9]"></div>
      <div name="text" class="pt-2 md:flex md:flex-col md:justify-evenly md:pt-4">
        <div class="text-xl text-[#e44] md:text-3xl">Mie Goleng</div>
        <div class="mt-2 text-[#b4b4b4] md:text-xl">Plant K103.</div>
        <div class="mt-2 text-[#b4b4b4] md:text-xl">500.02 UOG.</div>
      </div>
    </div>

    <div name="Buttons">
      <div class="flex gap-4 md:flex-col p-4 md:p-0">
        <div class="rounded-md shadow">
          <a href="#" class="inline-flex items-center justify-center rounded-md border border-transparent bg-indigo-600 px-5 py-3 text-base font-medium text-white hover:bg-indigo-700 md:text-xl"> Get started </a>
        </div>
        <div class="rounded-md shadow">
          <a href="#" class="inline-flex items-center justify-center rounded-md border border-transparent bg-indigo-50 px-5 py-3 text-base font-medium text-indigo-600 hover:bg-indigo-400 hover:text-white md:text-xl"> Learn more </a>
        </div>
      </div>
    </div>
  </div>
</div>

大型设备上的输出:

enter image description here

小型设备上的输出:

enter image description here

Tailwind play

Reactjs相关问答推荐

更新数据时有关CQR和更新UI的问题

如何将google地址lat收件箱设置为输入值?

使用setInterval判断数据的时间,然后在过期后从对象中删除;遇到性能问题

props 可以在Reaction中锻造吗?

Formik验证不适用于物料UI自动完成

Redux Store未触发React组件中的重新呈现

如果我使用 formik,如何在嵌套对象中写入正确的值?

React redux 工具包 useGetFilterProductsQuery 和 useGetFilterProductsByCategoriesQuery 未定义为函数

使用获取的数据更新状态,但在try console.log 时它给出未定义

如何在 React Native 中渲染下面的对象数组?

React中的功能性组件克隆优化

即使配置了 webpack.config.js,html-loader 也不起作用

在 Nextjs13 应用程序目录中呈现从 supabase 获取的数据

需要在窗口调整大小时更新 React 组件

React Final Form - 单选按钮在 FieldArray 中不起作用

如何在对话素材ui中设置边框半径?

vdom 最终更新了 dom(在比较之后)任何 dom 更改实际上应该触发整个树的重绘和回流,那么 vdom 有什么用?

哪个是创建 React 应用程序的更好方法?

为什么我在运行一些 npm react 命令时会收到这些警告?

在 React 中访问作为 prop 传递的状态变量