在CSS

时间:2016-06-29 02:13:12

标签: html css laravel laravel-5 blade

因此,在过去一小时内,我一直在尝试使用css属性position移动此图像。我的问题是我每次使用topbottom移动它时都无法正常工作。以下是使用所述属性和beforeafter的屏幕截图。您可以在下面找到我的html& CSS。最后,此position必须为absolute,否则图片将完全消失。

HTML

<section class="row posts">
    <div class="col-md-6 col-md-offset-3">
        <header><h3>What others have to say...</h3></header>
        @foreach($posts as $post)
            <article class="post" data-postid="{{ $post->id }}">
                <p>{{ $post->body }}</p>
                <div class="info">
                    Posted by {{ $post->user->user_name }} on {{ $post->created_at }}
                </div>
                <div class="interaction">
                    <a href="#" class="like heart"></a> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;|
                    <a href="#" class="like">Dislike</a>
                    @if(Auth::user() == $post->user)
                        |
                        <a href="#" class="edit">Edit</a> |
                        <a href="{{ route('post.delete', ['post_id' => $post->id]) }}">Delete</a>
                    @endif
                </div>
            </article>
        @endforeach
    </div>
</section>

CSS

.heart{
    background: url('http://localhost:8079/uncaughterror/public/src/img/web_heart_animation.png');
    background-position: left;
    background-repeat: no-repeat;
    height: 50px; width: 50px;
    cursor: pointer;
    position: absolute;
    left: 12px;
    bottom: 5px; //This or 'top' is what causes my entire problem
    background-size:1450px;
}

.heart:hover {
    background-position: right;
}

2 个答案:

答案 0 :(得分:1)

如何添加:

.interaction {
    position: relative;
}

答案 1 :(得分:1)

我认为你应该将no-repeat放在与background

相同的一行

这对我有用,我不知道为什么

https://jsfiddle.net/moongod101/2wh6b9rq/