简体   繁体   English

伪元素离我的DIV太远了

[英]Pseudo elements is to far from my DIV

I'm doing cookie bar for website 我正在为网站做Cookie栏

<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>

I've managed how to add icon via CSS lef to the paragraph, however I can't keep it left to cookie-content element. 我已经设法通过CSS lef向该段落添加图标,但是我不能将其留给cookie-content元素。 Could someone give me hint what I'm doing wrong? 有人可以提示我我做错了什么吗? I believe it's easy for skilled CSS guy :) 我相信熟练的CSS专家很容易:)

Here is a live example (the (I) circle must be located near to content): http://jsfiddle.net/dpastov/kU9F6/ 这是一个实时示例((I)圆圈必须位于内容附近): http : //jsfiddle.net/dpastov/kU9F6/

Use a percentage when setting the top position so it can scale to the content height. 设置顶部位置时使用百分比,以便可以缩放到内容高度。

#cookie-content
{
    position: relative;
}

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

DEMO 演示

您需要在css选择器中使用margin-top:some value #cookie-content:before是更新的小提琴

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM