gpt4 book ai didi

html - 不能将 div 与垂直菜单(其他 div)放在同一行

转载 作者:太空宇宙 更新时间:2023-11-04 09:48:30 26 4
gpt4 key购买 nike

我想将 div 与菜单放在同一行,但它总是位于菜单的底部,被另一个 div 插入。位置:#slider id 上的绝对没有帮助。

Jsfiddle

HTML

<div id=wrap>
<nav>
<ul>
<li class="var_nav">
<div class="link_bg"></div>
<div class="link_title">
<div class="icon">
<i class="fa fa-home fa-2x"></i>
</div>
</div>
</li>
</ul>
</nav>

我尝试放置显示属性,尝试更改 float 没有任何帮助,也无法在互联网上找到类似的东西。CSS

ul
{
margin:0px;
padding:0px;
list-style-type:none;
-webkit-backface-visibility: hidden; backface-visibility: hidden;

}
.var_nav
{

position:relative;
width:300px;
height:70px;
margin-bottom:5px;
background-color: #fff;
}
.link_bg
{
width:70px;
height:70px;
position:absolute;
background:#373541;
z-index:2;
}
.link_bg i
{
position:relative;
}
.link_title
{
position:absolute;
width:100%;
z-index:3;
color:#bc7c45;
}
.link_title:hover .icon
{
-webkit-transform:rotate(360deg);
-moz-transform:rotate(360deg);
-o-transform:rotate(360deg);
-ms-transform:rotate(360deg);
transform:rotate(360deg);
}
.var_nav:hover .link_bg
{
width:100%;
background:#373441;
-webkit-transition: all 0.3s ease-in-out;
-moz-transition: all 0.3s ease-in-out;
-o-transition: all 0.3s ease-in-out;
-ms-transition: all 0.3s ease-in-out;
transition: all 0.3s ease-in-out;
}
.var_nav:hover a
{
font-weight:bold;
-webkit-transition:all .5s ease-in-out;
-moz-transition:all .5s ease-in-out;
-o-transition:all .5s ease-in-out;
-ms-transition:all .5s ease-in-out;
transition:all .5s ease-in-out;
}
.icon
{
position:relative;
width:70px;
height:70px;
text-align:center;
color:#bc7c45;
-webkit-transition:all .5s ease-in-out;
-moz-transition:all .5s ease-in-out;
-o-transition:all .5s ease-in-out;
ms-transition:all .5s ease-in-out;
transition:all .5s ease-in-out;
float:left;
}
.icon i{top:22px;position:relative;}
a{
display:block;
position:absolute;
float:left;
font-family:arial;
font-size: 18px;
color:#bc7c45;
text-decoration:none;
width:100%;
height:70px;
text-align:center;
}
span
{
margin-top:25px;
display:block;
}
#slider
{
background:#373441;
width: 1000px;
height: 550px;
float: right;
}

最佳答案

使用 flex :

#wrap {
width: 1500px;
margin: 0 auto;
display: flex;
flex-direction: row;
}

并从所有位置移除所有定位属性!

https://jsfiddle.net/eupayxu8/2/

关于html - 不能将 div 与垂直菜单(其他 div)放在同一行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39299136/

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