不能将div放在与垂直菜单相同的行上(其他div)

时间:2016-09-02 19:00:19

标签: html css

我想将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>

我试图放置显示属性,尝试更改浮动没有任何帮助,无法在互联网上找到类似这样的东西。 的 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;
}

2 个答案:

答案 0 :(得分:1)

使用flex:

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

并从所有地方删除所有定位属性!

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

答案 1 :(得分:0)

您希望在导航栏旁边显示#slider吗?

只需将类似于around_nav的类添加到nav标记:

.around_nav
{
  float: left;
}

更新了fiddle