0
我想知道如何在最小化瀏覽器高度時使頁面固定。到目前爲止,身高反應迅速,一切都變得臃腫起來。如果您調整StackOverflow的大小,高度保持靜態並且不響應,這就是我要做的。我添加了一個基本形式的小提琴。垂直調整大小固定
https://jsfiddle.net/sto3d7e4/
HTML:
<div class="contactform">
<div class="bg">
<h1><img src="https://i.imgur.com/F8fAFJH.png" alt="">Contact Form</h1>
<form action=""
method="POST">
<input type="text" placeholder="Name" name="name">
<input type="text" placeholder="Program of Interest" name="Program">
<input type="text" placeholder="Gender" name="gender">
<textarea placeholder="Questions/Concerns"></textarea>
<input id="button" type="submit" value="Send">
</form>
</div>
</div>
CSS:
.contactform {
display: flex;
height: 100vh;
justify-content: center;
align-items: center;
background: #eee;
}
.contactform input {
display: block;
margin: 10px 0px;
height: 50px;
width: 400px;
background: transparent;
border: 0.1px solid;
outline-color: #eee;
color: #eee;
}
input::placeholder {
color: #eee;
padding: 0px 10px
}
.bg {
width: 80vw;
height: 80vh;
background: #89c4f4;
position: relative;
position: fixed;
}
.bg {
position: relative;
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
}
.bg h1 {
margin: 0;
color: #eee;
align-items: center;
justify-content: center;
display: flex;
}
.bg img {
height: 40px;
margin-right: 15px;
}
.bg textarea {
width: 400px;
height: 100px;
/max-width: 250px;
max-height: 200px;
background: transparent;
border: 0.1px solid #eee;
color: #eee;
outline-color: #eee;
}
textarea::placeholder {
color: #eee;
padding: 0px 10px
}
#button {
background:;
color: #eee;
border: 0.1px solid #eee;
transition: 0.2s all ease-in-out;
}
#button:hover {
background: #eee;
color: #89c4f4;
}
你使用'vh'作爲'height',即相對於視口(窗口)的高度...... –
@UsagiMiyamoto是解決它。不過,我仍然希望將視口的高度設置爲100%。有什麼辦法嗎? – RogerFedFan
試試'min-height:100vh;'...... –