Inserting a vertical barrier in the midst of the content

I am struggling to create a vertical divider and align the text properly in the top right corner of my screen.

https://i.sstatic.net/UqURE.png

Currently, I am facing issues with displaying the divider and positioning the text correctly.

<div class="row">  
    <div class="float-right">
      <span>Profile & Settings</span>
    </div>
    <div class="float-right sep">  
         <div class="septText"></div>  
    </div>
    <div class="float-right">
      <span>Logout</span>     
    </div>  
</div>

Css

.sep {
    display: flex;
    flex-direction: column;
    justify-content: center;
  }
  .sepText {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    flex: 1;
  }
  .sepText::before,
  .sepText::after {
    content: '';
    flex: 1;
    width: 1px;
    background: currentColor;
    /* matches font color */
    margin: .25em;
  }

Answer №1

I noticed that you've included the bootstrap 4 tag in your question. If you're working with bootstrap 4, there's a built-in flex utility that you can utilize here

<div class="d-flex flex-row justify-content-end">  
    <div class="">
        <span>Profile & Settings</span>
    </div>
    <div class="mx-2">|</div>
    <div class="">
        <span>Logout</span>     
    </div>  
</div>

Check out this code on JS Fiddle: here

Answer №2

  consider using a "container" instead of a "row", or apply display:inline or block to the row div.

 <div class="row" style="display:inline;" >  
<div class="float-right">
  <span>Profile & Settings</span>
</div>
<div class="float-right sep">  
     <div class="septText"></div>  
</div>
<div class="float-right">
  <span>Logout</span>     
</div>  
</div>

or

 <div class="container">

   <div class="float-right">
     <span>Profile & Settings</span>
    </div>
   <div class="float-right sep">  
     <div class="septText"></div>  
</div>
<div class="float-right">
  <span>Logout</span>     
</div>  

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 WordPress Customizer fails to update the CSS after making changes and saving them to an external stylesheet

I was looking for a way to improve the performance of my WordPress website by saving the styles from the Customizer into an external stylesheet for caching purposes. I found this code that allows me to save the custom styles into an external CSS file: $cs ...

Issues with Hovering over Button Contained in Slider

I can't seem to figure this out. It should be a simple fix. I have 5 slider images with black buttons that link to different galleries. I want the button background color to change on hover, but it's only working on one of the sliders. It seems ...

Tips for incorporating transitions into CSS styling

After successfully adding a picture over an element when hovering over it, I decided to include a transition: 0.2s; property but unfortunately the transition effect is not working as expected. Why is this happening? My intention is for the picture to smoot ...

Alert: CSS 4.0 Warning Validation - The value "rgb(0, 0, 0, 0.4)" is not valid for the "border" property

Wrapping up my asp core 3 project, I've been addressing various warnings that have popped up. However, one particular warning has me stumped. The CSS property in question is functioning perfectly, adding a touch of transparency to the black border. Wh ...

Exploring the functionalities of radio buttons and arrays in a Javascript experiment

Currently delving into the world of Javascript and struggling to wrap my head around creating a test using only pure Javascript (no jQuery). The goal is to: Present users with a question and provide radio button options for selection. Allow users to cho ...

What is the best method for eliminating tags from an HTML tag attribute using PHP?

I have a substantial amount of posts created using an old CMS. The content is in HTML markup, but unfortunately it's quite messy. It includes constructs like: ....<IMG alt="Хит сезона - <b>Лучшие фразы...</b>" src=" ...

Fluid Grid System with columns of specific dimensions

Recently delving into the world of Foundation Framework, I've just begun utilizing it for my projects. My current task involves crafting a responsive design with the help of the Foundation Grid system. Specifically, I've set up a grid layout for ...

Eliminating blank spaces below or above images when displayed horizontally

Displayed below is the image depicting my problem: I have discovered a cumbersome method to eliminate this unwanted whitespace by treating it as four separate lists and utilizing a complex for-loop to add elements. However, this approach limits the number ...

Listening for position changes using jQuery events

It is essential to be able to track the relative position of elements, especially when dealing with dynamic layout issues. Unfortunately, there are no built-in options in CSS to listen for changes in position() or offset() attributes. Reason: Changes in a ...

Another class is overriding the border of the text-box

I'm facing a challenge in customizing the material ui css. Specifically, I want to set the border color of a textbox to red. The issue arises when the bottom border gets overwritten. Upon investigation, I discovered that the culprit is the class MuiIn ...

Creating a typewriter animation using Tailwind CSS and Next.js

I am currently working on implementing a typewriter effect that is almost exactly how I want it. However, I am facing an issue with the printing process. Right now, each word gets printed on a new line and falls into place when done printing. What I actual ...

After deploying to Firebase, animations suddenly cease to function

After running npm run-script build and deploying my React app to Firebase hosting with firebase deploy, I encountered an issue where my animations stopped working. I'm puzzled as to why this is happening, especially since I've included keyframes ...

Navbar Growth Effect

I'm attempting to create an expanding effect in my navbar using Angular. When I click on "show information," the content should slide up. The issue is that the top part of my footer does not follow the effect. I have tried something like: <foot ...

Setting a variable equal to user input

When using a jQuery script, the elements for the details are dynamically created inside a jQuery function. However, there seems to be an issue with assigning the value from the variable "startLocation" to the input "detail_startLocation[]". Only the firs ...

Troubles with the placement of elements in a website due to

I have set up a table using PHP to display data in two columns from an XML feed. The first column appears correctly, but the second column is being cut off. For example, you can see the issue here: http://www.example.com Below is the CSS I am using: td ...

Tips for sorting items in Wordpress with JavaScript / on click?

I am currently utilizing a method similar to the one outlined in this resource from w3 schools for filtering elements within divs. However, I am facing challenges when attempting to integrate this script into my Aurora Wordpress site due to the removal of ...

Relocate the form element from its current position inside the form, and insert it into a different div

I have a sidebar on my website with a search/filter form. I am attempting to relocate one of the elements (a sort order dropdown) from this form, outside the form using CSS/JS and display it inside a div on the right side. Is it possible to do this without ...

What could be causing my jQuery script to not load properly on the first attempt?

I have a jQuery script set up on this particular webpage just before the ending body tag. Here is the script: <script> $(document).ready(function(){ var demomain = $(".demo-bg section"); var demomainW = demomain.height()+ 150 ...

Encountering Difficulty Fetching Data from JSON File Utilizing AngularJS

insert image description hereI am struggling to fetch data from a Json file using Angular Js. I am attempting to retrieve the Json data from a URL by clicking a button in Angular Js, and also add an empty tr td in a table when the button is clicked. ...

Issue with JQuery on Mobile Devices: Troubles with Dropdown Menu and Loading Function

Having some trouble with my JQuery code on mobile devices. The drop down menu isn't showing up on an iPhone, the load function isn't working to display the additional PHP page on a Samsung Edge 7, and the drop down doesn't seem to be functio ...