【问题标题】:div keeps moving to the left on resizediv 在调整大小时一直向左移动
【发布时间】:2021-12-30 19:59:22
【问题描述】:

我正在尝试使用 NextJS 和 tailwindcss 创建一个网站。但是每当调整浏览器窗口的大小时,div 都会向左移动。

这是调整大小时的样子,但文本应该居中

这是它在桌面上的外观

import { IoIosArrowForward } from "react-icons/io";
import Link from "next/link";

const About = () => {
  return (
    <div className="font-inter py-4 my-16 flex justify-center items-center flex-col"
      id="about">
      <p className="text-6xl font-bold text-gray-700 text-center">
        Hey, I&apos;m Anurag
      </p>
      <p className="text-2xl text-gray-600 text-center my-8">
        Hey there, I&apos;m a Frontend Developer based in India. <br />
        I&apos;m mainly focused on Frontend Development, and I also write blogs
        and design sometimes. <br />
        Apart from coding, I love listening to music!
      </p>
      <p className="flex justify-center">
        <Link href="https://github.com/kr-anurag" passHref>
          <a className="text-xl w-72 text-white font-medium px-4 py-3 rounded-full flex items-center justify-center bg-gradient-to-r from-[#12c2e9] via-[#c471ed] to-[#f64f59] shadow-xl hover:bg-gradient-to-l duration-100"
            aria-label="github-account"
            target="blank">
            Checkout my Github
            <IoIosArrowForward />
          </a>
        </Link>
      </p>
    </div>
  );
};

export default About;

【问题讨论】:

    标签: css next.js tailwind-css


    【解决方案1】:

    通过添加一个顺风类可以解决问题。
    w-full 添加到 #about div。 Here,是您的代码示例。请检查一下。

    有效!

    【讨论】:

    • 我已经试过了,还是不行
    • 这里是整个代码的 github repo:github.com/Kira272921/portfolio-template
    • @Kira 很遗憾,此链接不可用
    • 嘿,我已经解决了这个问题,我刚刚 fork 谢谢你:D
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-05-02
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多