2016-07-29 75 views
0

我試圖讓我的#image-square div從#inside-preview頂部9px。我不確定它爲什麼不起作用。我試過將其位置從absolute改爲relative以及topmargin-top,我加了block。我不明白爲什麼它不起作用。子元素沒有采取位置命令

請幫忙。

#outside-preview, #inside-preview { 
 
    border: 1px solid black; 
 
    border-radius: 8px; 
 
    /*display: inline-block;*/ 
 
} 
 
#outside-preview { 
 
    width: 500px; 
 
    height: 600px; 
 
    position: relative; 
 
    border-bottom-left-radius: 0px; 
 
    border-bottom-right-radius: 0px; 
 
} 
 
#inside-preview { 
 
    width: 440px; 
 
    height: 568px; 
 
    position: absolute; 
 
    z-index: 1; 
 
    left:5%; 
 
    bottom: 0; 
 
} 
 
#image-square { 
 
    top: 9x; 
 
    width: 400px; 
 
    height: 174px; 
 
    background: red; 
 
    position: relative; 
 
    display: block; 
 
    z-index: 2; 
 
}
<div> 
 
<div class="container" id="outside-preview"> 
 
    <div class="container" id="inside-preview"> 
 
     <div id="image-square"></div> 
 
    </div> 
 
</div> 
 
</div>

+2

錯字...'9x'應該是'9px' –

+0

是的,就是這樣。謝謝! – Becky

回答

-1

嘗試把 9px,而不是9X的開始..

+0

其實就是這樣。我以某種方式沒有在px中輸入'p'。我只花了20分鐘。哇。 – Becky

+0

它發生了,我最喜歡的是做一個jQuery的選擇聲明,並忘記把「。」對於班級或「#」代表... – Danimal

+0

不知道爲什麼downvote,我的回答是正確的。 – Danimal

0

試試這個:

#image-square { 
    margin-top: 9px; 
    width: 400px; 
    height: 174px; 
    background: red; 
    position: relative; 
    z-index: 2; 
}