Reputation: 53
How can I achieve that the gray arrow goes to the red position? To be above the button.
<div class="media">
<img class="rounded-circle profile-img" src="{{ user.userprofile.image.url }}">
<div class="one-above-the-other">
<div class="dropdown">
<a class="link-hover" data-toggle="dropdown">
<i class="fas fa-cog dark-icon"></i>
</a>
<div class="dropdown-menu my-drop-menu">
<span class="my-drop-menu-item-span">
<a class="my-drop-menu-item dropdown-item change-email link-hover"
data-id="{% url 'change-email' user.pk %}">
Change email
</a>
</span>
</div>
</div>
<div class="edit-profile-button">
<a class="edit-profile link-hover btn my-purple-btn">Edit profile</a>
</div>
</div>
</div>
Media
and rounded-circle
are from bootstrap. my-drop-menu
and edit-profile-button
are just for styling.
.one-above-the-other {
margin-left: auto;
margin-right: 0;
margin-top: auto;
margin-bottom: 0;
}
.profile-img {
width: 132px;
height: 132px;
}
Updated with the newest code.
Upvotes: 1
Views: 1008
Reputation: 1785
Try both methods below. Hope one of these works for you.
.one-above-another {
display: flex;
flex-direction: row-reverse;
justify-content: space-between;
width: 100%;
}
.one-above-another {
position: relative;
width: 100%;
}
.one-above-another .dropdown {
position: absolute;
top: 0;
right: 0;
}
Check this Jsfiddle link.
.media {
position: relative;
display: flex;
flex-direction: row;
justify-content: space-between;
align-items: flex-end !important;
}
/* .one-above-the-other {
margin-left: auto;
margin-right: 0;
margin-top: auto;
margin-bottom: 0;
} */
.circle-img {
display: inline-flex;
width: 100px;
height: 100px;
border-radius: 50%;
}
.dropdown-box {
position: absolute;
top: 0;
right: 0;
}
<link href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.0/css/bootstrap.min.css" rel="stylesheet"/>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script
src="https://stackpath.bootstrapcdn.com/bootstrap/4.1.0/js/bootstrap.min.js"></script>
<link href="https://stackpath.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet"/>
<div class="media">
<img class="circle-img" src="https://via.placeholder.com/300">
<div class="one-above-another">
<div class="dropdown-box">
<div class="dropdown">
<a class=" link-hover" data-toggle="dropdown">
<i class="fas fa-cog dark-icon"></i>
</a>
<div class="dropdown-menu my-drop-menu">
<span class="my-drop-menu-item-span">
<a class="my-drop-menu-item dropdown-item edit-post link-hover" data-id="">
Change email
</a>
</span>
</div>
</div>
</div>
<div class="edit-profile-button">
<a class="edit-profile link-hover btn my-purple-btn">Edit profile</a>
</div>
</div>
</div>
Upvotes: 1
Reputation: 1062
try like this
css
.one-above-the-other {
margin-left: auto;
margin-right: 0;
margin-top: auto;
margin-bottom: 0;
}
.dropdown{
position: absolute;
right: 0;
top: 0;
}
.edit-profile-button{
position: absolute;
left: 0;
bottom: 0;
}
Upvotes: 0