To position the logout button on the very right of the navigation bar, you can use CSS Flexbox on the .site-nav container. Here's how to modify your code:
HTML (no changes needed)
html Copy code
<header class="site-banner">
<nav class="site-nav">
<div class="banner-title">CA</div>
<a href="/CA/list">Liste</a>
<a href="/CA/creation">Créer</a> <span class="separator noselect">|</span>
<div class="banner-title">CRI</div>
<a href="/CRI/list">Liste</a>
<form method="post" action="{% url 'authent:logout' %}">
{% csrf_token %}
<button type="submit" class="logout-btn">Logout</button>
</form>
</nav>
</header>
CSS Solution
css Copy code
.site-nav {
display: flex;
align-items: center; /* Vertically center items */
gap: 1rem; /* Add some spacing between items */
}
/* Push the logout form to the right */
.site-nav form {
margin-left: auto;
}
.logout-btn {
background: none;
color: white;
font-weight: bold;
border: solid 2px white;
border-radius: 5px;
cursor: pointer;
padding: 0.25rem 0.5rem; /* Add some padding for better appearance */
}
/* Optional: Style the navigation items */
.site-nav > * {
white-space: nowrap; /* Prevent wrapping */
}
Alternative CSS (if you need more control)
If you want the other items to stay grouped on the left while only the logout moves to the right:
css Copy code
.site-nav {
display: flex;
align-items: center;
gap: 1rem;
}
/* Group for left-aligned items */
.nav-left-group {
display: flex;
align-items: center;
gap: 1rem;
margin-right: auto; /* Pushes everything after it to the right */
}
/* Then modify your HTML to wrap the left items */
<nav class="site-nav">
<div class="nav-left-group">
<div class="banner-title">CA</div>
<a href="/CA/list">Liste</a>
<a href="/CA/creation">Créer</a>
<span class="separator noselect">|</span>
<div class="banner-title">CRI</div>
<a href="/CRI/list">Liste</a>
</div>
<form method="post" action="{% url 'authent:logout' %}">
{% csrf_token %}
<button type="submit" class="logout-btn">Logout</button>
</form>
</nav>
Either solution will move your logout button to the far right of the navigation bar while keeping the other navigation items on the left.