Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Responsive onesite website padding to centre

Tags:

html

css

django

Im currently working on making onesie scrolling website but i came accross the problem. I want my text be on the centre of first "page" but i cant make it to looks good on phone and desktop at the same time. With padding-top: 50% it looks good at mobile but terrible at desktop, on the other hand padding-top: 7 looks good on desktop but not much at phone. Can someone help me finding the golden mean?

padding 50% also padding 50%

my html code:

section {
  width: 100%;
  height: 100vh;
}

.main section.page1 {
  background: #81D4FA;
}

.main section.page2 {
  background: #F5F5F5;
}

.main section.page3 {
  background: #81D4FA;
}


h1 {
  font-size: 8vw;
  color: #efefef;
  text-align: top;
  padding-top: 50%;
  padding-left: 15%;
}

h2
{
  list-style-type: none;
  font-size: 4vw;
  color: #efefef;
  text-align: center;
  padding-top: 2%;
}

a.read-more{
  border: 2px solid #efefef;
  text-decoration: none;
  color: inherit;
}


.notnav {
  list-style-type: none;
  font-size: 3vw;
  padding-top: 2%;
  padding-left: 5%;
  padding-right: 15%;
}
<div class="main">
  <section class="page1"> 
    <h1>
      ABOUT ME
      <li class="notnav">
        I am John, 19 years old computer science student. Mainly coding in python, but I am quick lerner and flexible person. I am currently intrested in Artificial Intelligence, Big Data and Design 
      </li>
    </h1>
    <h2>
      <a class="read-more" href='/about'>Read More</a>
    </h2>
  </section>
  <section class="page2">        
     <h1>
      PROJECTS
    </h1>
  </section>
  <section class="page3"> 
    <h1>
      CONTACT
    </h1>
  </section>
</div>
like image 599
bazzuk123 Avatar asked May 01 '26 20:05

bazzuk123


1 Answers

Try this(without the use of media-query);Sorry late to the party

section {
width: 100%;
height: 100vh;
}

.main section.page1 {
background: #81D4FA;
  }

 .main section.page2 {
    background: #F5F5F5;
    }

   .main section.page3 {
   background: #81D4FA;
   }

   .page1{
  display:flex;
  min-height: 100%;
  align-items: center;
 text-align: center;
 flex-direction: column;
justify-content:center;
}

h1 {
font-size: 8vw;
color: #efefef;    
   }

    h2
   {
   list-style-type: none;
   font-size: 4vw;
   color: #efefef;
   text-align: center;
   }

  a.read-more{
  border: 2px solid #efefef;
  text-decoration: none;
  color: inherit;
  }
  .notnav {
    list-style-type: none;
    font-size: 3vw;
    clear: both;
   }
like image 197
Abhilekh Gautam Avatar answered May 03 '26 09:05

Abhilekh Gautam



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!