【发布时间】:2016-08-07 06:52:29
【问题描述】:
这是我的html:
<div class="xoxo">
<div class="field">
<label for="xo">Destination</label>
<input class="animatedinput" type="text" id="xo" />
<div class="jabudunapoveda">Here</div>
</div>
</div>
这里是css:
.animatedinput {
padding: 1em 0 1em 2em;
position: absolute;
border: 0;
width: 100%;
margin: 0;
top: 0;
left: 0;
z-index: 3;
border-radius: 10px;
}
.field {
width: 100%;
height: auto;
position: relative;
border-radius: 10px;
border: 2px solid red;
}
label {
position: absolute;
width: 100%;
height: 100%;
line-height: 2em;
top: 0;
left: 1.5em;
z-index: 4;
}
.jabudunapoveda {
width: 100%;
height: 200px;
line-height: 200px;
top: 20px;
position: absolute;
background: #f4f4f4;
display: block;
border-radius: 0 0 10px 10px;
z-index: 2;
}
.xoxo {
width: 50%;
margin: 100px auto 4em;
z-index: 2;
height: auto;
border-radius: 10px;
}
- jabudunapoveda 类的 Div 必须绝对定位
- 为什么 .field 类的 div 上的红色边框只有 0px 高度?
- .field 的高度未知。
目标是使 .field 类的 div 高度为 100%,因此红色边框将在 jabudunapoveda div 的底部结束。
这里是codepen
【问题讨论】:
-
为什么是绝对的? codepen.io/anon/pen/zBmVXj?editors=1100 如果绝对是绝对需要,那么可能只将父级设置为绝对; codepen.io/anon/pen/qNJzwQ?editors=1100
标签: css