因此,在过去一小时内,我一直在尝试使用css属性position
移动此图像。我的问题是我每次使用top
或bottom
移动它时都无法正常工作。以下是使用所述属性和before的after的屏幕截图。您可以在下面找到我的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> |
<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;
}
答案 0 :(得分:1)
如何添加:
.interaction {
position: relative;
}
答案 1 :(得分:1)