我不知道如何更好地表达我的标题,所以我会在这里解释。我有一个带有 3 个 div 的 HTML/CSS 页面。
第一个,div.presentation,没有浮动规则。我想在它的右边制作菜单。
所以我得到了另外两个 divdiv.login和div.categories. 他们都有float: right;和clear: both;。
我想要这样的东西:
-------------------------------------- ------------------
|div.presentation | |div.login |
| | | |
| | | |
| | | |
| | ------------------
| |
| | ------------------
| | |div.categories |
| | | |
| | | |
| | | |
-------------------------------------- ------------------
Run Code Online (Sandbox Code Playgroud)
但是div.login和div.categories彼此放在一边。浮动规则在div.categories不存在时可以完美运行。
当我<div style="height:100px"></div>在div.login和之间添加时,我得到了我想要的东西div.categories,但我相信我们可以做得更好。这也太靠运气了。
这 3 个 div 是display:inline-block.
任何的想法 ?非常感谢。
我修改了你的CSS:
body {
width: 90%;
margin: auto;
font-family: Arial, Verdana, sans-serif;
font-size: 12px;
background: #e6f0ff;
}
header.beta {
position: absolute;
top: 0;
left: 0;
width: auto;
background: #fff7e0;
opacity: 0.8;
padding: 10px 50px;
color: #444443;
}
header.logo {
width: 90%;
height: 125px;
margin: auto;
margin-top: 60px;
margin-bottom: 30px;
border: 1px dotted grey;
}
nav.tabs {
display: none;
}
div.presentation, div.login, div.categories {
position: relative;
margin-top: 10px;
display: inline-block;
}
div.right {
position: relative;
float: right;
width: 25%;
}
div.presentation {
width: 70%;
clear: both;
}
div.login, div.categories {
width: 100%;
clear: both;
}
div.login header, div.presentation header, div.categories header {
font-size: 14px;
background: #0a97e2;
padding: 3px 15px;
color: white;
border-radius: 10px 10px 0 0;
}
div.login section, div.presentation section, div.categories section {
/*position: absolute;*/
width: 100%;
background: white;
border-radius: 0 0 5px 5px;
}
div.login section p, div.presentation section p {
/* changed this */
margin: 0px 10px;
padding: 3px 10px 3px 10px;
}
div.login section input {
display: block;
margin: auto;
margin-bottom: 10px;
}
/* added this */
div.categories ul {
margin: 0px 10px;
padding: 3px 10px 3px 10px;
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
12784 次 |
| 最近记录: |