html - 使垂直调整大小固定

标签 html css media-queries

我想知道如何在最小化浏览器高度时固定我的页面。截至目前,高度是敏感的,一切都被弄皱了。如果您调整 StackOverflow 的大小,高度将保持不变并且没有响应,这就是我想要的。我添加了一个基本形式的 fiddle 。

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;
}

最佳答案

尝试display:block

.menu_item{
    height: 15%;
    width: 45%;
    text-align: center;
}
.menu_icon{
    width:auto;
    height:100%;
}
.menu_item a {
  display:block;
}
<div class="menu_item">
    <a href="https://www.google.com">
        <img class="menu_icon" src="https://storage.googleapis.com/gweb-uniblog-publish-prod/static/blog/images/google-200x200.7714256da16f.png" alt="Templates"/>
        <span>Templates</span>
    </a>
</div>

关于html - 使垂直调整大小固定,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45498073/

相关文章:

javascript - 根据特定标签将 HTML 字符串拆分为多个部分?

javascript - 如何防止iframe影响浏览器历史记录

jquery - 如何检查第二页上的 iCheck

iphone - 如何为 iPhone 找出合适尺寸的背景图片

javascript - CSS - 1140px 网格 - IE 7,8 问题 - 媒体查询

android - 动态显示新闻文章(文本、图像)的最佳方式?除了网页 View ?

javascript - 为什么本地存储在javascript之后最后保存

javascript - 检查子元素是否没有特定的类?

html - 使用样式标签进行样式正确吗?

android - 像素比率 : are the "fake" pixel values on hi-res devices applied to all width properties, 或仅适用于选定的比率?