I'm relatively new to coding websites and I had a question about positioning material and window shrinkage I hope anyone could answer!
I wanted to place an image, a message, and a password input around the center (It worked on my screen but for the code snippet below [you may have to scroll around to see anything], there is no space below the password line, so I'm obviously doing something wrong.. it's suppose to be dead-center of the screen).
However, I do not think I'm positioning my elements in the most efficient way. I'm also trying to take into consideration if the user shrinks their window, scroll bars are supposed to come up and the empty space is supposed to disappear (maybe like Twitter's login page: https://twitter.com/login). For my code, when I shrink the window, there is still empty space and I believe that is bad UI?
So in summary, if anyone could give any tips on how to efficiently position words and images and possibly how to efficiently use css to consider window shrinking, I would appreciate it so much :) Any help is welcomed and thank you again!
.pretty {
text-align: center;
color: #00008b;
font-family: Lucida Console;
position: absolute;
top: 115%;
left: 39%;
}
.pwd {
text-align: center;
position: absolute;
top: 155%;
left: 38.5%;
}
.chatbubble {
height: 14%;
width: 6%;
position: absolute;
top: 102%;
left: 48.5%;
}
body {
background-color: #fff0f5;
}
#wrapper {
margin-left: auto;
margin-right: auto;
width: 960px;
}
.contain {
position: relative;
height: 200px;
}
html {
height: 100%;
}
<!DOCTYPE html>
<html>
<div id="wrapper">
<head>
<title> Log In </title>
<link href="loginstyle.css" type="text/css" rel="stylesheet">
<script language="JavaScript">
function showPass(form, e) {
e.preventDefault();
var pass = form.pwd.value;
var pass1 = "webdesign"
if (pass == pass1) {
window.location.href = 'https://www.google.com'
} else {
window.location.href = 'https://www.youtube.com/watch?v=dQw4w9WgXcQ'
}
}
</script>
</head>
<body>
<div class="contain">
<img class="chatbubble" src="chatbubble.png" alt="Chat Bubble" />
<p class="pretty center">Welcome to a <br/> digital photobook. <br/> Please enter the password to continue: <br/> </p>
<form class="pwd center" onsubmit="showPass(this, event)">
Password: <input type="password" name="pwd" />
<input type="submit" value="Log In" />
</form>
</div>
</body>
</div>
</html>