2016-10-22 6 views
1

Meine Überschrift,'SKoolTalk 'ist fehl am Platz und ich versuchte ein paar Möglichkeiten, es zu zentrieren, aber es hat nicht funktioniert. Ich habe versucht mit position: absolute und Ausrichtung, aber es reagiert nicht. Ich möchte, dass Überschrift so sein:Wie zentriere ich meine Überschrift?

How it should look on all devices no matter the width.

Hier ist mein Code:

function displaySignInError() { 
 
    var schoolName = document.getElementById('schoolNameBox').value.toLowerCase(); 
 
    switch (schoolName) { 
 
    case 'new horizon gurukul': 
 
     window.location = "NHGLogin.php"; 
 
     break; 
 
    default: 
 
     var schoolErrorMessage = document.getElementById('schoolErrorMessage'); 
 
     schoolErrorMessage.innerHTML = "Please Enter a valid school name, still if invalid schoold does not exist."; 
 
     schoolErrorMessage.style.color = 'red'; 
 
     
 
    } 
 
}
@import url('https://fonts.googleapis.com/css?family=Catamaran:100,200,300,400,500,600,700,800,900|Droid+Sans:400,700|Josefin+Sans:100,100i,300,300i,400,400i,600,600i,700,700i|Open+Sans:300,300i,400,400i,600,600i,700,700i,800,800i|Oxygen:300,400,700|Roboto:100,100i,300,300i,400,400i,500,500i,700,700i,900,900i|Ubuntu:300,300i,400,400i,500,500i,700,700i'); 
 

 
body { 
 
    height: 100vh; 
 
} 
 

 
#abhimanyu { 
 
    z-index: -1; 
 
    background-color: green; 
 
    width: 50%; 
 
    float: left; 
 
    height: 50%; 
 
} 
 

 
#arjun { 
 
    z-index: -1; 
 
    background-color: orange; 
 
    width: 50%; 
 
    float: right; 
 
    height: 50%; 
 
} 
 

 
#bheem { 
 
    z-index: -1; 
 
    background-color: red; 
 
    width: 50%; 
 
    float: left; 
 
    height: 50%; 
 
} 
 

 
#eklavya { 
 
    z-index: -1; 
 
    background-color: purple; 
 
    float: right; 
 
    width: 50%; 
 
    height: 50%; 
 
} 
 

 
#container { 
 
    width: 30em; 
 
    background-color: #eee; 
 
    height: 30em; 
 
    border-radius: 50%; 
 
    position: fixed; 
 
    top: 50%; 
 
    left: 50%; 
 
    transform: translate(-50%, -50%); 
 
    transform: -webkit-translate(-50%, -50%); 
 
    transform: -ms-translate(-50%, -50%); 
 
} 
 

 
#wrapper { 
 
    width: 30rem; 
 
    height: 30rem; 
 
    border-radius: 50%; 
 
} 
 

 

 
#schoolSubmitButton { 
 
    margin-top: 35px; 
 
    text-align: center; 
 
    background-color: white; 
 
    border: 2px solid #fef; 
 
    height: 2em; 
 
    width: 10em; 
 
} 
 

 
#schoolName { 
 
    margin-bottom: 40px; 
 
    position: fixed; 
 
    top: 60%; 
 
    left: 50%; 
 
    transform: translate(-50%, -50%); 
 
    transform: -webkit-translate(-50%, -50%); 
 
    transform: -ms-translate(-50%, -50%); 
 
    text-align: center; 
 
} 
 

 
#schoolNameBox { 
 
    height: 2em; 
 
    border: none; 
 
    width: 26em; 
 
    margin-left: 0; 
 
    padding-left: 10px; 
 
} 
 

 
#schoolSubmitButton p { 
 
    position: relative; 
 
    top: 50%; 
 
    position: relative; 
 
    top: 30%; 
 
    left: 50%; 
 
    transform: translate(-50%, -70%); 
 
    transform: -webkit-translate(-50%, -70%); 
 
    transform: -ms-translate(-50%, -70%); 
 
} 
 

 
/* 
 
::-webkit-input-placeholder { 
 
    padding-left: 10px; 
 
} 
 

 
:-moz-placeholder { 
 
    padding-left: 10px; 
 
} 
 

 
:-ms-input-placeholder { 
 
    padding-left: 10px; 
 
} 
 
*/ 
 

 
#schoolErrorMessage { 
 
    text-decoration: none; 
 
    position: relative; 
 
    top: 6em; 
 
    color: black; 
 
    width: 140%; 
 
    float: left; 
 
    font-size: 15px; 
 
    position: relative; 
 
    right: 20%; 
 
} 
 

 
#schoolNameDiv { 
 
    position: fixed; 
 
    top: 60%; 
 
    left: 50%; 
 
    transform: translate(-50%, -50%); 
 
    transform: -webkit-translate(-50%, -50%); 
 
    transform: -ms-translate(-50%, -50%); 
 
    text-align: center; 
 
} 
 

 
#main-heading { 
 
    color: green; 
 
    text-decoration: none; 
 
    position: absolute; 
 
    left: 43%; 
 
    right: 57%; 
 
    font-size: 24px; 
 
    z-index: 10; 
 
} 
 

 
#main-heading h2 span { 
 
    color: orange; 
 
} 
 

 
#schoolAvatar { 
 
    height: 9em; 
 
    width: 9em; 
 
    border-radius: 50%; 
 
    position: fixed; 
 
    top: 25%; 
 
    left: 50%; 
 
    transform: translate(-50%, -50%); 
 
    transform: -webkit-translate(-50%, -50%); 
 
    transform: -ms-translate(-50%, -50%); 
 
} 
 

 
.footerHR { 
 
    border-top: 1px solid grey; 
 
    position: absolute; 
 
    bottom: 20px; 
 
    margin-bottom: 20px; 
 
}
<!DOCTYPE html> 
 
<html> 
 
    <head> 
 
    <title>NHG</title> 
 
    <meta charset="UTF-8"/> 
 
    <meta name="viewport" content="width=device-width, initial-scale=1.0"/> 
 
    <link type="text/css" rel="stylesheet" href="css/normalize.css"/> 
 
    <link type="text/css" rel="stylesheet" href="css/style.css"/> 
 
    <link type="text/css" rel="stylesheet" href="css/resposive.css"/> 
 
    <script src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script> 
 
    </head> 
 
    <body> 
 
    <div id="abhimanyu"></div> 
 
    <div id="arjun"></div> 
 
    <br> 
 
    <div id="bheem"></div> 
 
    <div id="eklavya"></div> 
 
    <header> 
 
      <div id="main-head"> 
 
       <!--  REMEMBER TO STYLE THE HEADING AND SIGN UP LINK  --> 
 
       <a href="#" id="main-heading"><h2><span>sKool</span>Talk</h2></a> 
 
      </div> 
 
    </header> 
 
    <section> 
 
     <div id="container"> 
 
     <div id="wrapper"> 
 
      <img src="https://i.imgsafe.org/a40bbe047e.png" alt="avatar" id="schoolAvatar" align="middle"> 
 
      <div id="schoolNameDiv"> 
 
      <div id="schoolName"> 
 
       <input type="text" name="schoolName" id="schoolNameBox" placeholder="Enter your School Name..."> 
 
       <br> 
 
       <button type="submit" id="schoolSubmitButton" onclick="displaySignInError();"> 
 
       <p>Next</p> 
 
       </button> 
 
       <br> 
 
      </div> 
 
      <br> 
 
      <p id="schoolErrorMessage">School Doesn't exist? Tell your principal about our website now!</p> 
 
      </div> 
 
     </div> 
 
     </div> 
 
    </section> 
 
    <br> 
 
    <footer> 
 
     <div class="footerHR"> 
 
     </div> 
 
    </footer> 
 
    <script src="JS/script.js"></script> 
 
    </body> 
 
</html>

+1

Alle Ihre dom Elemente zwingt es mit in Ihre Web-Seite zu sein 'float: left' oder 'position: absolute' und das ist falsch. Ihre verschachtelten Elemente müssen die Stile ihrer Eltern erhalten. Ich empfehle Ihnen, alle Elemente neu zu entwerfen und neu zu schreiben. – oguzhancerit

+0

Was genau meinen Sie damit, indem Sie alle Elemente neu schreiben? –

+0

Sie sollten clear verwenden: beide nach der Verwendung von Float oder sonst erhalten Sie mehr Problem. –

Antwort

0

Erstens, trennen Sie Ihre Überschrift zwei Teile mit span. Ihr Elternelement von h2 Breite: 100%. Children von h2 (spans) Breite 50%, eine von 'float: left', eine von 'float: right' und danach ausrichten Eigenschaft ihre Position auf der Seite.

function displaySignInError() { 
 
    var schoolName = document.getElementById('schoolNameBox').value.toLowerCase(); 
 
    switch (schoolName) { 
 
    case 'new horizon gurukul': 
 
     window.location = "NHGLogin.php"; 
 
     break; 
 
    default: 
 
     var schoolErrorMessage = document.getElementById('schoolErrorMessage'); 
 
     schoolErrorMessage.innerHTML = "Please Enter a valid school name, still if invalid schoold does not exist."; 
 
     schoolErrorMessage.style.color = 'red'; 
 
     
 
    } 
 
}
@import url('https://fonts.googleapis.com/css?family=Catamaran:100,200,300,400,500,600,700,800,900|Droid+Sans:400,700|Josefin+Sans:100,100i,300,300i,400,400i,600,600i,700,700i|Open+Sans:300,300i,400,400i,600,600i,700,700i,800,800i|Oxygen:300,400,700|Roboto:100,100i,300,300i,400,400i,500,500i,700,700i,900,900i|Ubuntu:300,300i,400,400i,500,500i,700,700i'); 
 

 
body { 
 
margin : 0px; 
 
    height: 100vh; 
 
} 
 

 
#abhimanyu { 
 
    z-index: -1; 
 
    background-color: green; 
 
    width: 50%; 
 
    float: left; 
 
    height: 50%; 
 
} 
 

 
#arjun { 
 
    z-index: -1; 
 
    background-color: orange; 
 
    width: 50%; 
 
    float: right; 
 
    height: 50%; 
 
} 
 

 
#bheem { 
 
    z-index: -1; 
 
    background-color: red; 
 
    width: 50%; 
 
    float: left; 
 
    height: 50%; 
 
} 
 

 
#eklavya { 
 
    z-index: -1; 
 
    background-color: purple; 
 
    float: right; 
 
    width: 50%; 
 
    height: 50%; 
 
} 
 

 
#container { 
 
    width: 30em; 
 
    background-color: #eee; 
 
    height: 30em; 
 
    border-radius: 50%; 
 
    position: fixed; 
 
    top: 50%; 
 
    left: 50%; 
 
    transform: translate(-50%, -50%); 
 
    transform: -webkit-translate(-50%, -50%); 
 
    transform: -ms-translate(-50%, -50%); 
 
} 
 

 
#wrapper { 
 
    width: 30rem; 
 
    height: 30rem; 
 
    border-radius: 50%; 
 
} 
 

 

 
#schoolSubmitButton { 
 
    margin-top: 35px; 
 
    text-align: center; 
 
    background-color: white; 
 
    border: 2px solid #fef; 
 
    height: 2em; 
 
    width: 10em; 
 
} 
 

 
#schoolName { 
 
    margin-bottom: 40px; 
 
    position: fixed; 
 
    top: 60%; 
 
    left: 50%; 
 
    transform: translate(-50%, -50%); 
 
    transform: -webkit-translate(-50%, -50%); 
 
    transform: -ms-translate(-50%, -50%); 
 
    text-align: center; 
 
} 
 

 
#schoolNameBox { 
 
    height: 2em; 
 
    border: none; 
 
    width: 26em; 
 
    margin-left: 0; 
 
    padding-left: 10px; 
 
} 
 

 
#schoolSubmitButton p { 
 
    position: relative; 
 
    top: 50%; 
 
    position: relative; 
 
    top: 30%; 
 
    left: 50%; 
 
    transform: translate(-50%, -70%); 
 
    transform: -webkit-translate(-50%, -70%); 
 
    transform: -ms-translate(-50%, -70%); 
 
} 
 

 
/* 
 
::-webkit-input-placeholder { 
 
    padding-left: 10px; 
 
} 
 

 
:-moz-placeholder { 
 
    padding-left: 10px; 
 
} 
 

 
:-ms-input-placeholder { 
 
    padding-left: 10px; 
 
} 
 
*/ 
 

 
#schoolErrorMessage { 
 
    text-decoration: none; 
 
    position: relative; 
 
    top: 6em; 
 
    color: black; 
 
    width: 140%; 
 
    float: left; 
 
    font-size: 15px; 
 
    position: relative; 
 
    right: 20%; 
 
} 
 

 
#schoolNameDiv { 
 
    position: fixed; 
 
    top: 60%; 
 
    left: 50%; 
 
    transform: translate(-50%, -50%); 
 
    transform: -webkit-translate(-50%, -50%); 
 
    transform: -ms-translate(-50%, -50%); 
 
    text-align: center; 
 
} 
 

 
#main-heading { 
 
    text-decoration: none; 
 
    position: absolute; 
 
    font-size: 24px; 
 
    z-index: 10; 
 
    display: block; 
 
    text-align: center; 
 
    width: 100%; 
 
} 
 

 
#main-heading h2 span:first-child { 
 
    color: orange; 
 
    display: inline-block; 
 
    width: 50%; 
 
    float: left; 
 
    text-align: right; 
 
} 
 

 
#main-heading h2 span:nth-child(2) { 
 
    color: green; 
 
    display: inline-block; 
 
    width: 50%; 
 
    float: right; 
 
    text-align: left; 
 
} 
 

 
#schoolAvatar { 
 
    height: 9em; 
 
    width: 9em; 
 
    border-radius: 50%; 
 
    position: fixed; 
 
    top: 25%; 
 
    left: 50%; 
 
    transform: translate(-50%, -50%); 
 
    transform: -webkit-translate(-50%, -50%); 
 
    transform: -ms-translate(-50%, -50%); 
 
} 
 

 
.footerHR { 
 
    border-top: 1px solid grey; 
 
    position: absolute; 
 
    bottom: 20px; 
 
    margin-bottom: 20px; 
 
}
<!DOCTYPE html> 
 
<html> 
 
    <head> 
 
    <title>NHG</title> 
 
    <meta charset="UTF-8"/> 
 
    <meta name="viewport" content="width=device-width, initial-scale=1.0"/> 
 
    <link type="text/css" rel="stylesheet" href="css/normalize.css"/> 
 
    <link type="text/css" rel="stylesheet" href="css/style.css"/> 
 
    <link type="text/css" rel="stylesheet" href="css/resposive.css"/> 
 
    <script src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script> 
 
    </head> 
 
    <body> 
 
    <div id="abhimanyu"></div> 
 
    <div id="arjun"></div> 
 
    <br> 
 
    <div id="bheem"></div> 
 
    <div id="eklavya"></div> 
 
    <header> 
 
      <div id="main-head"> 
 
       <!--  REMEMBER TO STYLE THE HEADING AND SIGN UP LINK  --> 
 
       <a href="#" id="main-heading"><h2><span>sKool</span><span>Talk</span></h2></a> 
 
      </div> 
 
    </header> 
 
    <section> 
 
     <div id="container"> 
 
     <div id="wrapper"> 
 
      <img src="https://i.imgsafe.org/a40bbe047e.png" alt="avatar" id="schoolAvatar" align="middle"> 
 
      <div id="schoolNameDiv"> 
 
      <div id="schoolName"> 
 
       <input type="text" name="schoolName" id="schoolNameBox" placeholder="Enter your School Name..."> 
 
       <br> 
 
       <button type="submit" id="schoolSubmitButton" onclick="displaySignInError();"> 
 
       <p>Next</p> 
 
       </button> 
 
       <br> 
 
      </div> 
 
      <br> 
 
      <p id="schoolErrorMessage">School Doesn't exist? Tell your principal about our website now!</p> 
 
      </div> 
 
     </div> 
 
     </div> 
 
    </section> 
 
    <br> 
 
    <footer> 
 
     <div class="footerHR"> 
 
     </div> 
 
    </footer> 
 
    <script src="JS/script.js"></script> 
 
    </body> 
 
</html>

0

Dies ist, wenn Sie Ihren Text genau Zentrum zu sein!

<!DOCTYPE html> 
 
<html> 
 

 
<head> 
 
    <title>NHG</title> 
 
    <meta charset="UTF-8" /> 
 
    <meta name="viewport" content="width=device-width, initial-scale=1.0" /> 
 
    <link type="text/css" rel="stylesheet" href="css/normalize.css" /> 
 
    <link type="text/css" rel="stylesheet" href="css/style.css" /> 
 
    <link type="text/css" rel="stylesheet" href="css/resposive.css" /> 
 
    <script src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script> 
 
    <style> 
 
    @import url('https://fonts.googleapis.com/css?family=Catamaran:100,200,300,400,500,600,700,800,900|Droid+Sans:400,700|Josefin+Sans:100,100i,300,300i,400,400i,600,600i,700,700i|Open+Sans:300,300i,400,400i,600,600i,700,700i,800,800i|Oxygen:300,400,700|Roboto:100,100i,300,300i,400,400i,500,500i,700,700i,900,900i|Ubuntu:300,300i,400,400i,500,500i,700,700i'); 
 
body { 
 
    height: 100vh; 
 
} 
 
#abhimanyu { 
 
    z-index: -1; 
 
    background-color: green; 
 
    width: 50%; 
 
    float: left; 
 
    height: 50%; 
 
} 
 
#arjun { 
 
    z-index: -1; 
 
    background-color: orange; 
 
    width: 50%; 
 
    float: right; 
 
    height: 50%; 
 
} 
 
#bheem { 
 
    z-index: -1; 
 
    background-color: red; 
 
    width: 50%; 
 
    float: left; 
 
    height: 50%; 
 
} 
 
#eklavya { 
 
    z-index: -1; 
 
    background-color: purple; 
 
    float: right; 
 
    width: 50%; 
 
    height: 50%; 
 
} 
 
#container { 
 
    width: 30em; 
 
    background-color: #eee; 
 
    height: 30em; 
 
    border-radius: 50%; 
 
    position: fixed; 
 
    top: 50%; 
 
    left: 50%; 
 
    transform: translate(-50%, -50%); 
 
    transform: -webkit-translate(-50%, -50%); 
 
    transform: -ms-translate(-50%, -50%); 
 
} 
 
#wrapper { 
 
    width: 30rem; 
 
    height: 30rem; 
 
    border-radius: 50%; 
 
} 
 
#schoolSubmitButton { 
 
    margin-top: 35px; 
 
    text-align: center; 
 
    background-color: white; 
 
    border: 2px solid #fef; 
 
    height: 2em; 
 
    width: 10em; 
 
} 
 
#schoolName { 
 
    margin-bottom: 40px; 
 
    position: fixed; 
 
    top: 60%; 
 
    left: 50%; 
 
    transform: translate(-50%, -50%); 
 
    transform: -webkit-translate(-50%, -50%); 
 
    transform: -ms-translate(-50%, -50%); 
 
    text-align: center; 
 
} 
 
#schoolNameBox { 
 
    height: 2em; 
 
    border: none; 
 
    width: 26em; 
 
    margin-left: 0; 
 
    padding-left: 10px; 
 
} 
 
#schoolSubmitButton p { 
 
    position: relative; 
 
    top: 50%; 
 
    position: relative; 
 
    top: 30%; 
 
    left: 50%; 
 
    transform: translate(-50%, -70%); 
 
    transform: -webkit-translate(-50%, -70%); 
 
    transform: -ms-translate(-50%, -70%); 
 
} 
 
/* 
 
::-webkit-input-placeholder { 
 
    padding-left: 10px; 
 
} 
 

 
:-moz-placeholder { 
 
    padding-left: 10px; 
 
} 
 

 
:-ms-input-placeholder { 
 
    padding-left: 10px; 
 
} 
 
*/ 
 

 
#schoolErrorMessage { 
 
    text-decoration: none; 
 
    position: relative; 
 
    top: 6em; 
 
    color: black; 
 
    width: 140%; 
 
    float: left; 
 
    font-size: 15px; 
 
    position: relative; 
 
    right: 20%; 
 
} 
 
#schoolNameDiv { 
 
    position: fixed; 
 
    top: 60%; 
 
    left: 50%; 
 
    transform: translate(-50%, -50%); 
 
    transform: -webkit-translate(-50%, -50%); 
 
    transform: -ms-translate(-50%, -50%); 
 
    text-align: center; 
 
} 
 
#main-heading { 
 
    color: green; 
 
    text-decoration: none; 
 
    position: absolute; 
 
    font-size: 24px; 
 
    z-index: 10; 
 
    text-align : center; 
 
} 
 
#main-head{ 
 
    position: absolute; 
 
    width: 100%; 
 
    text-align: center; 
 
    top: 10%; 
 
} 
 
#main-heading h2 span { 
 
    color: orange; 
 
} 
 
#schoolAvatar { 
 
    height: 9em; 
 
    width: 9em; 
 
    border-radius: 50%; 
 
    position: fixed; 
 
    top: 25%; 
 
    left: 50%; 
 
    transform: translate(-50%, -50%); 
 
    transform: -webkit-translate(-50%, -50%); 
 
    transform: -ms-translate(-50%, -50%); 
 
} 
 
.footerHR { 
 
    border-top: 1px solid grey; 
 
    position: absolute; 
 
    bottom: 20px; 
 
    margin-bottom: 20px; 
 
    
 
} 
 
    </style> 
 
</head> 
 

 
<body> 
 
    <div id="abhimanyu"></div> 
 
    <div id="arjun"></div> 
 
    <br> 
 
    <div id="bheem"></div> 
 
    <div id="eklavya"></div> 
 
    <header> 
 
    <div id="main-head"> 
 
     <h2>sKool Talk</h2> 
 
    </div> 
 
    </header> 
 
    <section> 
 
    <div id="container"> 
 
     <div id="wrapper"> 
 
     <img src="https://i.imgsafe.org/a40bbe047e.png" alt="avatar" id="schoolAvatar" align="middle"> 
 
     <div id="schoolNameDiv"> 
 
      <div id="schoolName"> 
 
      <input type="text" name="schoolName" id="schoolNameBox" placeholder="Enter your School Name..."> 
 
      <br> 
 
      <button type="submit" id="schoolSubmitButton" onclick="displaySignInError();"> 
 
       <p>Next</p> 
 
      </button> 
 
      <br> 
 
      </div> 
 
      <br> 
 
      <p id="schoolErrorMessage">School Doesn't exist? Tell your principal about our website now!</p> 
 
     </div> 
 
     </div> 
 
    </div> 
 
    </section> 
 
    <br> 
 
    <footer> 
 
    <div class="footerHR"> 
 
    </div> 
 
    </footer> 
 
    <script src="JS/script.js"></script> 
 
</body> 
 

 
</html>

Das ist etwas, was ich denke, Sie ist näher an, was Sie im Kopf haben

<html><head> 
 
    <title>NHG</title> 
 
    <meta charset="UTF-8"> 
 
    <meta name="viewport" content="width=device-width, initial-scale=1.0"> 
 
    <link type="text/css" rel="stylesheet" href="css/normalize.css"> 
 
    <link type="text/css" rel="stylesheet" href="css/style.css"> 
 
    <link type="text/css" rel="stylesheet" href="css/resposive.css"> 
 
    <script src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script> 
 
    <style> 
 
    @import url('https://fonts.googleapis.com/css?family=Catamaran:100,200,300,400,500,600,700,800,900|Droid+Sans:400,700|Josefin+Sans:100,100i,300,300i,400,400i,600,600i,700,700i|Open+Sans:300,300i,400,400i,600,600i,700,700i,800,800i|Oxygen:300,400,700|Roboto:100,100i,300,300i,400,400i,500,500i,700,700i,900,900i|Ubuntu:300,300i,400,400i,500,500i,700,700i'); 
 
body { 
 
    height: 100vh; 
 
} 
 
#abhimanyu { 
 
    z-index: -1; 
 
    background-color: green; 
 
    width: 50%; 
 
    float: left; 
 
    height: 50%; 
 
    text-align: right; 
 
} 
 
#abhimanyu h2 { 
 
    position: relative; 
 
    top: 10%; 
 
    padding-right: 5px; 
 
    color: orange; 
 
} 
 
#arjun { 
 
    z-index: -1; 
 
    background-color: orange; 
 
    width: 50%; 
 
    float: right; 
 
    height: 50%; 
 
    text-align: left; 
 
} 
 
#arjun h2 { 
 
    position: relative; 
 
    top: 10%; 
 
    padding-left: 5px; 
 
    color: green; 
 
} 
 
#bheem { 
 
    z-index: -1; 
 
    background-color: red; 
 
    width: 50%; 
 
    float: left; 
 
    height: 50%; 
 
} 
 
#eklavya { 
 
    z-index: -1; 
 
    background-color: purple; 
 
    float: right; 
 
    width: 50%; 
 
    height: 50%; 
 
} 
 
#container { 
 
    width: 30em; 
 
    background-color: #eee; 
 
    height: 30em; 
 
    border-radius: 50%; 
 
    position: fixed; 
 
    top: 50%; 
 
    left: 50%; 
 
    transform: translate(-50%, -50%); 
 
    transform: -webkit-translate(-50%, -50%); 
 
    transform: -ms-translate(-50%, -50%); 
 
} 
 
#wrapper { 
 
    width: 30rem; 
 
    height: 30rem; 
 
    border-radius: 50%; 
 
} 
 
#schoolSubmitButton { 
 
    margin-top: 35px; 
 
    text-align: center; 
 
    background-color: white; 
 
    border: 2px solid #fef; 
 
    height: 2em; 
 
    width: 10em; 
 
} 
 
#schoolName { 
 
    margin-bottom: 40px; 
 
    position: fixed; 
 
    top: 60%; 
 
    left: 50%; 
 
    transform: translate(-50%, -50%); 
 
    transform: -webkit-translate(-50%, -50%); 
 
    transform: -ms-translate(-50%, -50%); 
 
    text-align: center; 
 
} 
 
#schoolNameBox { 
 
    height: 2em; 
 
    border: none; 
 
    width: 26em; 
 
    margin-left: 0; 
 
    padding-left: 10px; 
 
} 
 
#schoolSubmitButton p { 
 
    position: relative; 
 
    top: 50%; 
 
    position: relative; 
 
    top: 30%; 
 
    left: 50%; 
 
    transform: translate(-50%, -70%); 
 
    transform: -webkit-translate(-50%, -70%); 
 
    transform: -ms-translate(-50%, -70%); 
 
} 
 
/* 
 
::-webkit-input-placeholder { 
 
    padding-left: 10px; 
 
} 
 

 
:-moz-placeholder { 
 
    padding-left: 10px; 
 
} 
 

 
:-ms-input-placeholder { 
 
    padding-left: 10px; 
 
} 
 
*/ 
 

 
#schoolErrorMessage { 
 
    text-decoration: none; 
 
    position: relative; 
 
    top: 6em; 
 
    color: black; 
 
    width: 140%; 
 
    float: left; 
 
    font-size: 15px; 
 
    position: relative; 
 
    right: 20%; 
 
} 
 
#schoolNameDiv { 
 
    position: fixed; 
 
    top: 60%; 
 
    left: 50%; 
 
    transform: translate(-50%, -50%); 
 
    transform: -webkit-translate(-50%, -50%); 
 
    transform: -ms-translate(-50%, -50%); 
 
    text-align: center; 
 
} 
 
#main-heading { 
 
    color: green; 
 
    text-decoration: none; 
 
    position: absolute; 
 
    font-size: 24px; 
 
    z-index: 10; 
 
    text-align : center; 
 
} 
 
#main-head{ 
 
    position: absolute; 
 
    width: 100%; 
 
    text-align: center; 
 
    top: 10%; 
 
} 
 
#main-heading h2 span { 
 
    color: orange; 
 
} 
 
#schoolAvatar { 
 
    height: 9em; 
 
    width: 9em; 
 
    border-radius: 50%; 
 
    position: fixed; 
 
    top: 25%; 
 
    left: 50%; 
 
    transform: translate(-50%, -50%); 
 
    transform: -webkit-translate(-50%, -50%); 
 
    transform: -ms-translate(-50%, -50%); 
 
} 
 
.footerHR { 
 
    border-top: 1px solid grey; 
 
    position: absolute; 
 
    bottom: 20px; 
 
    margin-bottom: 20px; 
 
    
 
} 
 
    </style> 
 
</head> 
 

 
<body> 
 
    <div id="abhimanyu"> 
 
    <h2>sKool</h2> 
 
    </div> 
 
    <div id="arjun"> 
 
    <h2>sKool</h2> 
 
    </div> 
 
    <br> 
 
    <div id="bheem"></div> 
 
    <div id="eklavya"></div> 
 
    <section> 
 
    <div id="container"> 
 
     <div id="wrapper"> 
 
     <img src="https://i.imgsafe.org/a40bbe047e.png" alt="avatar" id="schoolAvatar" align="middle"> 
 
     <div id="schoolNameDiv"> 
 
      <div id="schoolName"> 
 
      <input type="text" name="schoolName" id="schoolNameBox" placeholder="Enter your School Name..."> 
 
      <br> 
 
      <button type="submit" id="schoolSubmitButton" onclick="displaySignInError();"> 
 
       <p>Next</p> 
 
      </button> 
 
      <br> 
 
      </div> 
 
      <br> 
 
      <p id="schoolErrorMessage">School Doesn't exist? Tell your principal about our website now!</p> 
 
     </div> 
 
     </div> 
 
    </div> 
 
    </section> 
 
    <br> 
 
    <footer> 
 
    <div class="footerHR"> 
 
    </div> 
 
    </footer> 
 
    <script src="JS/script.js"></script> 
 

 

 
</body></html>

0

Statt position: absolute;text-align : center; versuchen auf #text-heading

0

Lösung:

#main-heading { 
    color: green; 
    text-decoration: none; 
    text-align:center; 
    font-size: 24px; 
    z-index: 30; 
    position: absolute; 
    width: 100%; 
} 

function displaySignInError() { 
 
    var schoolName = document.getElementById('schoolNameBox').value.toLowerCase(); 
 
    switch (schoolName) { 
 
    case 'new horizon gurukul': 
 
     window.location = "NHGLogin.php"; 
 
     break; 
 
    default: 
 
     var schoolErrorMessage = document.getElementById('schoolErrorMessage'); 
 
     schoolErrorMessage.innerHTML = "Please Enter a valid school name, still if invalid schoold does not exist."; 
 
     schoolErrorMessage.style.color = 'red'; 
 
     
 
    } 
 
}
@import url('https://fonts.googleapis.com/css?family=Catamaran:100,200,300,400,500,600,700,800,900|Droid+Sans:400,700|Josefin+Sans:100,100i,300,300i,400,400i,600,600i,700,700i|Open+Sans:300,300i,400,400i,600,600i,700,700i,800,800i|Oxygen:300,400,700|Roboto:100,100i,300,300i,400,400i,500,500i,700,700i,900,900i|Ubuntu:300,300i,400,400i,500,500i,700,700i'); 
 

 
body { 
 
    height: 100vh; 
 
} 
 

 
#abhimanyu { 
 
    z-index: -1; 
 
    background-color: green; 
 
    width: 50%; 
 
    float: left; 
 
    height: 50%; 
 
} 
 

 
#arjun { 
 
    z-index: -1; 
 
    background-color: orange; 
 
    width: 50%; 
 
    float: right; 
 
    height: 50%; 
 
} 
 

 
#bheem { 
 
    z-index: -1; 
 
    background-color: red; 
 
    width: 50%; 
 
    float: left; 
 
    height: 50%; 
 
} 
 

 
#eklavya { 
 
    z-index: -1; 
 
    background-color: purple; 
 
    float: right; 
 
    width: 50%; 
 
    height: 50%; 
 
} 
 

 
#container { 
 
    width: 30em; 
 
    background-color: #eee; 
 
    height: 30em; 
 
    border-radius: 50%; 
 
    position: fixed; 
 
    top: 50%; 
 
    left: 50%; 
 
    transform: translate(-50%, -50%); 
 
    transform: -webkit-translate(-50%, -50%); 
 
    transform: -ms-translate(-50%, -50%); 
 
} 
 

 
#wrapper { 
 
    width: 30rem; 
 
    height: 30rem; 
 
    border-radius: 50%; 
 
} 
 

 

 
#schoolSubmitButton { 
 
    margin-top: 35px; 
 
    text-align: center; 
 
    background-color: white; 
 
    border: 2px solid #fef; 
 
    height: 2em; 
 
    width: 10em; 
 
} 
 

 
#schoolName { 
 
    margin-bottom: 40px; 
 
    position: fixed; 
 
    top: 60%; 
 
    left: 50%; 
 
    transform: translate(-50%, -50%); 
 
    transform: -webkit-translate(-50%, -50%); 
 
    transform: -ms-translate(-50%, -50%); 
 
    text-align: center; 
 
} 
 

 
#schoolNameBox { 
 
    height: 2em; 
 
    border: none; 
 
    width: 26em; 
 
    margin-left: 0; 
 
    padding-left: 10px; 
 
} 
 

 
#schoolSubmitButton p { 
 
    position: relative; 
 
    top: 50%; 
 
    position: relative; 
 
    top: 30%; 
 
    left: 50%; 
 
    transform: translate(-50%, -70%); 
 
    transform: -webkit-translate(-50%, -70%); 
 
    transform: -ms-translate(-50%, -70%); 
 
} 
 

 
/* 
 
::-webkit-input-placeholder { 
 
    padding-left: 10px; 
 
} 
 

 
:-moz-placeholder { 
 
    padding-left: 10px; 
 
} 
 

 
:-ms-input-placeholder { 
 
    padding-left: 10px; 
 
} 
 
*/ 
 

 
#schoolErrorMessage { 
 
    text-decoration: none; 
 
    position: relative; 
 
    top: 6em; 
 
    color: black; 
 
    width: 140%; 
 
    float: left; 
 
    font-size: 15px; 
 
    position: relative; 
 
    right: 20%; 
 
} 
 

 
#schoolNameDiv { 
 
    position: fixed; 
 
    top: 60%; 
 
    left: 50%; 
 
    transform: translate(-50%, -50%); 
 
    transform: -webkit-translate(-50%, -50%); 
 
    transform: -ms-translate(-50%, -50%); 
 
    text-align: center; 
 
} 
 

 

 
#main-heading { 
 
    color: green; 
 
    text-decoration: none; 
 
    text-align:center; 
 
    font-size: 24px; 
 
    z-index: 30; 
 
    position: absolute; 
 
    width: 100%; 
 
} 
 

 
#main-heading h2 span { 
 
    color: orange; 
 
} 
 

 
#schoolAvatar { 
 
    height: 9em; 
 
    width: 9em; 
 
    border-radius: 50%; 
 
    position: fixed; 
 
    top: 25%; 
 
    left: 50%; 
 
    transform: translate(-50%, -50%); 
 
    transform: -webkit-translate(-50%, -50%); 
 
    transform: -ms-translate(-50%, -50%); 
 
} 
 

 
.footerHR { 
 
    border-top: 1px solid grey; 
 
    position: absolute; 
 
    bottom: 20px; 
 
    margin-bottom: 20px; 
 
}
<!DOCTYPE html> 
 
<html> 
 
    <head> 
 
    <title>NHG</title> 
 
    <meta charset="UTF-8"/> 
 
    <meta name="viewport" content="width=device-width, initial-scale=1.0"/> 
 
    <link type="text/css" rel="stylesheet" href="css/normalize.css"/> 
 
    <link type="text/css" rel="stylesheet" href="css/style.css"/> 
 
    <link type="text/css" rel="stylesheet" href="css/resposive.css"/> 
 
    <script src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script> 
 
    </head> 
 
    <body> 
 
    <header> 
 
      <div id="main-head"> 
 
       <!--  REMEMBER TO STYLE THE HEADING AND SIGN UP LINK  --> 
 
       <a href="#" id="main-heading"><h2><span>sKool</span>Talk</h2></a> 
 
      </div> 
 
    </header> 
 
    <div id="abhimanyu"></div> 
 
    <div id="arjun"></div> 
 
    <br> 
 
    <div id="bheem"></div> 
 
    <div id="eklavya"></div> 
 
    <section> 
 
     <div id="container"> 
 
     <div id="wrapper"> 
 
      <img src="https://i.imgsafe.org/a40bbe047e.png" alt="avatar" id="schoolAvatar" align="middle"> 
 
      <div id="schoolNameDiv"> 
 
      <div id="schoolName"> 
 
       <input type="text" name="schoolName" id="schoolNameBox" placeholder="Enter your School Name..."> 
 
       <br> 
 
       <button type="submit" id="schoolSubmitButton" onclick="displaySignInError();"> 
 
       <p>Next</p> 
 
       </button> 
 
       <br> 
 
      </div> 
 
      <br> 
 
      <p id="schoolErrorMessage">School Doesn't exist? Tell your principal about our website now!</p> 
 
      </div> 
 
     </div> 
 
     </div> 
 
    </section> 
 
    <br> 
 
    <footer> 
 
     <div class="footerHR"> 
 
     </div> 
 
    </footer> 
 
    <script src="JS/script.js"></script> 
 
    </body> 
 
</html>

0

geben #main-head feste Breite und:

#main-head { 
position :absolute; 
top:0; 
bottom:0; 
left:0; 
right:0; 
} 

ODER

#main-head { 
width:100px; 
margin:0 auto; 
}