gpt4 book ai didi

html - 将一个元素设置在另一个元素旁边

转载 作者:行者123 更新时间:2023-11-28 15:00:39 26 4
gpt4 key购买 nike

我有一个列表,它占据了 100% 的高度空间,我试图在它旁边设置一个图像框

fiddle :https://jsfiddle.net/wrdvkgyj/

我通过将我的图像容器设置为内联来关闭,但图片似乎又被推出了,我不确定这里出了什么问题..

HTML:

<div id="wrapper">
<div class="project-list">
<ul>
<li>item1</li>
<li>item2</li>
<li>item3</li>
<li>item4</li>
</ul>
</div>
<div id="image-container">
<div class="image-holder">
<img src="https://semantic-ui.com/images/wireframe/image.png">
</div>
</div>
<div class="description-container"></div>
</div>

CSS:

/* wrapper  */
html, body {
width: 100%;
height: 100%;
}

#wrapper {
width: 100%;
height: 100%;
border: 1px solid black;
}

/* project list */
.project-list {
border: 1px solid #cccc;
float: left;
font-size: 25px;
width: 30%;
height: 100%;
overflow-x: hidden;
}

.project-list ul {
list-style: none;
padding: 0;
margin: 0;
}

.project-list li {
float: left;
clear: left;
width: 100%;
padding: 10px;
transition: all .3s ease;
}

.project-list li:nth-child(even){
background-color: #f8f8f8;
}

/*li-hover*/
.project-list li:hover {
color: red;
background-color: #d8d8d8;
cursor: pointer;
}

最佳答案

您所做的一切都是正确的,只是将 #image-container 的宽度更改为 0。并将 box-sizing: border-box; 添加到您的 css。希望这有帮助

*{
box-sizing: border-box;
}

html, body {
width: 100%;
height: 100%;
}

#wrapper {
width: 100%;
height: 100%;
border: 1px solid black;
box-sizing: border-box;
}

/* project list */
.project-list {
border: 1px solid #cccc;
float: left;
font-size: 25px;
width: 30%;
height: 100%;
overflow-x: hidden;
}

.project-list ul {
list-style: none;
padding: 0;
margin: 0;
}

.project-list li {
float: left;
clear: left;
width: 100%;
padding: 10px;
transition: all .3s ease;
}

.project-list li:nth-child(even){
background-color: #f8f8f8;
}

/*li-hover*/
.project-list li:hover {
color: red;
background-color: #d8d8d8;
cursor: pointer;
}

#image-container{
width: 0;
}
<div id="wrapper">
<div class="project-list">
<ul>
<li>item1</li>
<li>item2</li>
<li>item3</li>
<li>item4</li>
</ul>
</div>
<div id="image-container">
<div class="image-holder">
<img src="https://semantic-ui.com/images/wireframe/image.png">
</div>
</div>
<div class="description-container"></div>
</div>

关于html - 将一个元素设置在另一个元素旁边,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50221527/

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