skip to Main Content

I have a div inside a div, my first div is a square, inside this frame I have a h2 tag, my frame works fine on mobile and browser, but when I shrink my h2 tag it stays outside the frame, inside the frame how can I make the h2 tag responsive

picture

home.js:

function Home() {

  return (
    <div className="home-page">

      <div className="home-header">

        <div className='home-first>
          <h2>BAROO</h2>
      
        </div>
      </div>
    </div>


  )
}

export default Home

Home.css:

.home-page {
    display: flex;
    flex-direction: column;
    flex: 0.65;
    max-width: 100%;
    width: 100%;
    background-color: #00ACFE;
  }

.home-header {
    flex-direction: column;
    display: flex;
    border-radius: 20px;
    background-color: rgb(200, 244, 244);
    max-width: 90%;
    margin-left: 65px;
    margin-top: 0px;
    height: 700px;
    width: 100%;
  }

  
  h2 {
    font-size: 100px;
  
    transform: translate(-50%, -50%);
    margin-left: 700px;
    margin-top: 200px;
  }
  @media screen and (max-width: 800px) {
    .home-header {
      max-width: 90%;
      margin-left: auto;
      margin-right: auto; 
      
    }
    .home-first >h2{
      font-size: 100px;
      width: 100%;
    }
    
  }

3

Answers


  1. center in mobile view, margin-left:auto; margin-right:auto;

    @media screen and (max-width: 800px) {
      .home-header {
        max-width: 83%;
        margin-left: auto;
        margin-right: auto;
      }
    }
    
    Login or Signup to reply.
  2. try removing flex-direction: column; from .home-header {}

    Login or Signup to reply.
  3. Actually I didn’t understand why you used transform: translate(-50%, -50%) and margin-left: 700px I assume that you wanted it to be in the center, so I used align-items: center; to .home-header

    codesandbox

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search