2014-07-26 16 views
0

我做的餅乾棒網站僞元素是遠從我的DIV

<div id="cookie" class="md_blkn"> 
    <div id="cookie-content"> 
     <h3 class="pts">WE USE COOKIES</h3> 
     <p>We use cookies to ensure that we give you the best experience on our website. If you continue without changing your settings, we will assume that you are happy to receive all cookies from this website. We use cookies to ensure that we give you the best experience on our website.</p> <a class="btn-gray-light-solid-s mbs" href="#">OKAY GOT IT</a> 
    </div> 
</div> 

我已經成功瞭如何通過CSS添加圖標LEF段落,但我不能把它留下來cookie內容元素。有人能給我提示我做錯了什麼嗎?我認爲這是很容易熟練CSS傢伙:)

這是一個活生生的例子(在(我)圈必須靠近到內容): http://jsfiddle.net/dpastov/kU9F6/

回答

0

設置頂部位置,以便它可以在使用百分比縮放到內容高度。

#cookie-content 
{ 
    position: relative; 
} 

#cookie-content:before 
{ 
    top: 40%; 
    left: -75px; 
} 

DEMO

+0

我需要保持近段,如果你讓面板大(我)會遠離段落。所以我想知道如何保持它總是靠近P –

+0

基本上我認爲我必須用#cookie-content做些事情:之前我不知道什麼 –

+0

@Dmytro我剛更新了我的答案,以便如何工作。 –

0

你需要使用margin-top:some value你的CSS選擇器#cookie-content:before 這裏是更新fiddle