2013-12-12 40 views
1

我做了一个小导航。如果你点击一个加号,动画开始并且下拉菜单打开。我该如何定位我的IMG?

但是,我不知道如何可以用CSS来定位元素。我尝试过所有类型的操作组合。有谁知道我做错了什么?

这是CSS:

body { 
    background-image: url(bg.png); 
    background-size: cover; 
    background-repeat: no-repeat; 
} 

html,body { 
    height: 100%; 
} 

.aspectwrapper { 
    display: inline-block; 
/* shrink to fit */ 
    width: 100%; 
/* whatever width you like */ 
    position: relative; 
/* so .content can use position: absolute */ 
} 

.aspectwrapper::after { 
    padding-top: 56.25%; 
/* percentage of containing block _width_ */ 
    display: block; 
    content: ''; 
} 

.content { 
    position: absolute; 
    top: 0; 
    bottom: 0; 
    right: 0; 
    left: 0; 
/* follow the parent's edges */ 
    outline: thin dashed green; 
/* just so you can see the box */ 
} 

#links { 
    position: relative; 
    left: 300px; 
} 

的 '链接' DIV就是整个导航部分位于股利。我想我需要定位这个div。

这是HTML代码:

<div class="aspectwrapper"> 
    <div class="content"> 
     <div class="links"> 
      <ul> 
       <li><a href="#ontwerp"><img height="20" src="1.png"></a></li> 

       <li><a href="#object"><img height="20" src="2.png"></a></li> 

       <li><a href="#bouwkunde"><img height="20" src="3.png"></a></li> 

       <li><a href="#contact"><img height="20" src="4.png"></a></li> 

       <li><a href="#winkel"><img height="20" src="5.png"></a></li> 
      </ul> 
     </div> 
    </div> 
</div> 

我希望有人能帮助我

+0

我的答案解决了你的问题吗? –

回答

3

在你的CSS,你定义的链接类作为一个ID。因此,更改:

#links { 
    position: relative; 
    left: 300px; 
} 

.links { 
    position: relative; 
    left: 300px; 
} 

这里的小提琴:http://jsfiddle.net/5Ejgx/

希望帮助!

相关问题