【发布时间】:2014-10-24 16:06:18
【问题描述】:
我正在努力实现这个结果:
但是我在定位东西时遇到了很多麻烦。尤其是顶部的输入框和按钮,看起来像是连在一起的,尤其是很难定位。我最终正确定位了它,但是我不得不使用绝对定位,这对布局的其余部分产生了一些不良影响。
这是我到目前为止所做的:
HTML
<div class="main">
<div class="logo">
<h1>Shopping<span class="orange">List</span></h1>
</div>
<div class="add-wrapper">
<div class="add add-input">
<input type="text" placeholder="Add Items">
</div>
<div class="add add-btn">
<button type="submit">Add</button>
</div>
</div>
<div class="list-wrapper">
<ol>
<li class="item">
<h3>Bread</h3>
</li>
<li class="item"></li>
<li class="item"></li>
<li class="item"></li>
<li class="item"></li>
</ol>
</div>
</div>
CSS
html {
box-sizing: border-box;
}
*, *:before, *:after {
box-sizing: inherit;
}
.main {
margin: auto;
width: 600px;
margin-top: 50px;
text-align: center;
}
.logo{
text-align: center;
}
.add-wrapper {
margin-top: 35px;
position: relative;
}
.add {
position: absolute;
}
.add-input > input {
height: 60px;
border: 4px solid #1ABC9C;
border-right: none;
background-color: transparent;
outline: none;
padding-left: 10px;
font-size: 1.9em;
width: 540px;
}
.add-btn > button {
border: none;
outline: none;
background-color: #1ABC9C;
color: #ECF0F1;
height: 60px;
width: 60px;
cursor: pointer;
}
.add-btn>button:hover {
background-color: #01A383;
}
.add-btn {
left: 540px;
}
.item {
margin-top: 10px;
width: 100%;
height: 60px;
background-color: #DEE4E8;
text-align: left;
line-height: 60px;
padding-left: 10px;
}
如您所见,它存在一些问题。我觉得我做错了这一切,而且我缺少一些基本的东西。
对实现这一目标的最佳/更好方法有什么想法吗?
【问题讨论】:
标签: html css layout alignment absolute