gpt4 book ai didi

html - 在html中构建一个菜单,内容在右边

转载 作者:太空宇宙 更新时间:2023-11-04 14:27:03 24 4
gpt4 key购买 nike

JsFiddle:Here

所以我遇到了两个问题,而且我似乎无法找出解决方案。一:我需要内容 div 的最小高度为菜单的高度(我不想使用最小高度规则)二:当content div大于菜单时,我需要菜单的高度是content div的大小。

HTML:

<div class="container">
<div class="menu">
<ul>
<li>Menu1</li>
<li>Menu2</li>
<li>Menu3</li>
<li>Menu4</li>
</ul>
</div>
<div class="content">content</div>
</div>
<div class="container">
<div class="menu">
<ul>
<li>Menu1</li>
<li>Menu2</li>
<li>Menu3</li>
<li>Menu4</li>
</ul>
</div>
<div class="content">content2</div>
</div>

CSS:

.container{
padding: 5px 0;
clear: both;
}
.menu{
float:left;
background-color: green;
}
.menu ul{
list-style-type: none;
padding: 0;
margin:0;
}
.content{
background-color: yellow;
padding-left: 50px;
}

编辑:

在弄乱 jsFiddle 之后,我想出了 This ,这里有人似乎有问题吗?本质上它使用显示表和显示表行...

HTML:

<div class="table">
<div class="row">
<div class="cell first">
asdfasdf
</div>
<div class="cell second">
Content 1
</div>
</div>
</div>

<div class="table">
<div class="row">
<div class="cell first">
asdfasdf
</div>
<div class="cell second">
Cotent 2
</div>
</div>
</div>

CSS:

.table{
display table;
padding-top: 20px;
}

.row{
display: table-row;
}

.first{
background-color:green;
}

.second{
background-color:yellow;
width: 100%;
}
.cell{
display:table-cell;
}

最佳答案

如果您希望两列的高度相同,请尝试使用 one true layout方法:

Adjusted JSFiddle here.

/* CSS */

.container{
padding: 5px 0;
clear: both;
overflow: hidden;
}

.menu, .content {
padding-bottom: 999999px;
margin-bottom: -999999px;
}

.menu{
float:left;
background-color: green;
}
.menu ul{
list-style-type: none;
padding: 0;
margin:0;
}
.content{
background-color: yellow;
padding-left: 50px;
}

关于html - 在html中构建一个菜单,内容在右边,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19469382/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com