Adjust the Bootstrap settings to center the title on the navbar and shift the logout button to the right side

Is there a way to centrally align the title "My project" in the navbar while also keeping the logout button on the right of the same line as the title?

<div class="navbar navbar-inverse navbar-fixed-top" role="navigation">
  <div class="container">
    <div style="display: flex; justify-content: space-between;">
        <h1>My Project</h1>
      <form class="navbar-form" method="post" action="{{url_for("logout")}}">
        <i class="glyphicon glyphicon-user white"></i>
        <font style="color:#FFFFFF;font-size:10px;padding-right:5px;">{{ g.user.get_name() }}</font>
        <button id="logout" type="submit" class="btn btn-success">Logout</button>
      </form>
    </div>
  </div>
</div>

Answer №1

Try out this code snippet:

<div class="navbar navbar-inverse navbar-fixed-top" role="navigation">
    <div class="container">
        <div>
            <h1 align="center"><div class="navbar-collapse collapse">
                <form class="navbar-form navbar-right" method="post" action="{{url_for("logout")}}">My Amazing Project
                    <i class="glyphicon glyphicon-user white"></i>
                    <font style="color:#FFFFFF;font-size:10px;padding-right:5px;">{{ g.user.get_name() }}</font>
                    <input id="logout" type="submit" class="btn btn-success" value="Logout">
                </form>
            </div></h1>
        </div>

    </div>
</div>

This <h1> tag is quite long, isn't it?)))))

Answer №2

<nav class="navbar navbar-inverse navbar-fixed-top" role="navigation">  <div class="container-fluid">
<!-- Brand and toggle get grouped for better mobile display -->
<div class="navbar-header" style="float: center;">
    <form class="navbar-form " method="post" action="{{url_for("logout")}}">
      <div align="center" >

    <h1 > Welcome to My Project  <i class="glyphicon glyphicon-user white"></i> </h1>

    <font style="color:#FFFFFF;font-size:10px;padding-right:5px;">{{ g.user.get_name() }}</font>
      <p class="collapse navbar-collapse" id="bs-example-navbar-collapse-1" >

  <ul class="nav navbar-nav navbar-right">
      <p class="navbar-right"><button id="logout" type="submit" class="btn btn-success">Logout</button>
  </p>
  </ul>
</p>
      </div>

    </form>
</div>
</div>
</nav>

http://jsfiddle.net/ySX3q/

Answer №3

It is possible to achieve this using basic CSS techniques

<style>
.container {
    position:relative;  
}
.navbar-collapse {
    position:absolute;
    right:0px;
    top:0px;    
}
</style>

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

The Vue Swiper does not support inline containers in my code

I am facing an issue with the layout of my simple swiper in my vue app. The containers are not inline as expected, causing the second one to appear under the first. Additionally, I am struggling with making the slider element visible only within the viewpo ...

Image tag src displaying a React icon causes a malfunction

I am currently following a guide on ReactJS and encountered an error when trying to use an Img tag as directed in the tutorial. <Img src={keepLogo} alt="Google keep logo" /> This resulted in the following error: Warning: Invalid value for ...

What is the process for immediately changing the background color of an input field as soon as text is entered?

I am encountering an issue with the code snippet provided below. My goal is to change the background color of an input field as soon as I start typing something into it. The scenario involves 4 input fields where if the submit button is clicked and any f ...

Click on a text link to scroll to and either open or toggle a Bootstrap accordion

I am currently working on a bootstrap accordion with the following structure: <div class="support-accordion"> <div class="accordion" id="accordionExample"> <div class="accordion-item ...

Changes in an image element's transition can result in either resizing or shifting positions

When I apply an opacity transition to an img element as shown here, I notice that the size of the image changes or it appears to move at the start and end of the transition. Below is a simple CSS code for styling: img{ height:165px; width:165px; ...

JavaScript detecting improper XHTML syntax

Is there an effective method to detect malformed XHTML within a string using JavaScript? Given that my page allows user-generated XHTML (from trusted users) to be inserted into the DOM, I aim to identify unclosed or overly closed tags. If found, I intend ...

Tips for retaining user input in an input box using HTML and AngularJS

Is there a way to retain a user's input in an input box? This is the current code snippet: <input type="text" ng-model="userText" placeholder="Enter text here"> However, I am looking for a solution that will allow the entered text to persist ...

Adjust vertical dimension using rich text editor tag

I am currently using JSF with RichFaces version v.3.3.1.GA. I am trying to decrease the height style of the rich:editor tag (using TinyMCE), but for some reason it does not seem to be changing. <rich:editor id="transactionResult" style="height: 10px;" ...

Troubleshooting: Custom icons not displaying in Next.js application

Every time I attempt to use icons that I have loaded into my source code, I keep getting this default icon displayed: https://i.sstatic.net/AWhcW.png I'm uncertain about what exactly is causing this issue. Here is the layout of my file tree for ref ...

What causes two elements with display: inline-block; position: absolute; to overlap instead of appearing side by side?

It is recommended to use position: relative; in order to achieve inline block behavior for both elements and prevent them from overlapping. This positions the elements inline next to each other as they are recognized as blocks. When using position: absolu ...

Want to easily switch between pictures in the Gallery?

I've created a gallery using jQuery, CSS & HTML and now I want to implement next and previous image buttons. I have added the buttons to the page and written functions for them, but I am struggling with the implementation. Here is my code, if anyone h ...

Confirm that the form is valid prior to displaying the Bootstrap modal popup

My PHP file contains a simple form and a Bootstrap modal. When the submit button is clicked, the Bootstrap modal will be displayed. The form includes: https://i.sstatic.net/10R2r.png I want to validate the fields in the form. If successful, I then need ...

Incorporating PHP variables within JavaScript

As a beginner in web development, I am working on creating an application that heavily relies on JavaScript but also includes PHP/MySQL to prevent users from viewing quiz answers by inspecting the page source. The key pages involved in this project are: in ...

Interacting with a PNG file using a border radius in Internet Explorer 9 is causing issues with its transparency

Encountering an issue with IE9 where a white to gray gradient box appears around the transparent PNG on hover/selection. There is also a border radius applied to the thumbnail. Any ideas on how to fix this problem? Here is an example of the issue: https ...

increasing the size of a picture without resorting to a pop-up window

Struggling to implement a product details tab within a table that features a clickable image. When the image is clicked, it should enlarge but the width doesn't adjust accordingly. I'm using bootstrap 5.3 and can't seem to identify the root ...

What is the best way to insert an image into a div?

Trying to figure out how to place a flower inside the red box in my div that is overlaid on another one with a higher z-index. The picture I added doesn't seem to show up properly. Any advice on how to make this work? ...

Is it possible to rotate a group within an SVG without altering the orientation of the gradient fill it contains?

In my search on SO, I came across a lot of information about rotating gradients. However, my issue is the opposite. I have an icon created from multiple paths that I want to fill with a vertical gradient. I have successfully done this and it works well. ...

The GMaps API v3 is currently being loaded, but is not displaying on the webpage

Although the maps are supposed to be loading, I'm having trouble actually seeing them appear. Troubleshooting function initialize() { var myLatlng = new google.maps.LatLng(-25.363882,131.044922); var mapOptions = { zoom: 4, center: myLat ...

Identify the element with the active class name as the primary focus

Can anyone assist with this issue? Below is an example of the code I am working with: import React, { useRef, useEffect } from "react"; function App() { const inputRef = useRef(null); useEffect(() => { const testElement = document.qu ...

javascript cannot utilize html reset functionality

My drop down menu includes an onChange event that triggers a JavaScript method. However, when I select a new value and then click the reset button, the dropdown reverts back to its original value but the onChange event does not fire. <select onChange= ...