Experiencing difficulty aligning a span element with surrounding text

Check out the image , and also view it with the help of dev tools. The issue at hand is that I'm struggling to align it in the same line as the text on the left and right sides. Here's the messy code snippet along with a disclaimer:

<p class="lead posebne-ocene d-block d-sm-flex"><span class="kvalitet-usluga"></span>
Kvalitet Usluge
<span>
<span class="bar" style="background-color: #CBE8DA;"></span>
<span class="mala-ocena">20</span>
</span>
</p>

The classes "d-block" and "d-sm-flex" as well as "lead" are part of Bootstrap. Here is the corresponding CSS:

.bar {
        display: inline-block;
        width: 350px;
        /* margin-top: 2px;
        margin-right: 10px; */
        height: 20px;
}

.posebne-ocene {
    display: flex;
    position: relative;
    text-align: left;
    padding-left: 110px;
    justify-content: space-between;
}

.kvalitet-usluga {
    display: block;
    width: 30px;
    height: 30px;
    position: absolute;
    left: 70px;
    background-position: center;
    background-image: url('../slike/Ikonice/kvalitetUsluga.svg');
    border-radius: 20px;
}

I attempted adding

align-self: baseline;

to the ".bar" class and experimented with different margins and paddings but without success.

Answer №1

To enhance the styling of your outer span which encloses two other span elements, consider adding a class name and utilizing flexbox with align-items: center;. Check out the example below for reference:

.bar {
    display: inline-block;
    width: 350px;
    /* margin-top: 2px;
    margin-right: 10px; */
    height: 20px;
}

posebne-ocene {
    display: flex;
    position: relative;
    text-align: left;
    justify-content: space-between;
    align-items: center;
    flex-direction: row;
}

.wrapper {
    display: flex;
    align-items:center;
}
<p class="lead posebne-ocene d-block d-sm-flex">
  <span class="kvalitet-usluga"></span>
    Kvalitet Usluge
  <span class="wrapper">
    <span class="bar" style="background-color: #CBE8DA;"></span>
    <span class="mala-ocena">20</span>
  </span>
</p>

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

Modifying a single element within a class with Jquery

Is it possible to create a stack of pages on a website using JQuery? I found this image that shows what I'm trying to achieve: image. Instead of applying ID css for each page, I'd like to use JQuery. While researching similar questions, I came ac ...

The flexbox container is not displaying properly

I have rows containing two flex divs each. One div displays an image, while the other has text. I'm puzzled as to why some divs display correctly while others have overflowing text. Refreshing the page resolves this issue, but it resurfaces if I clea ...

What's the best way to arrange 6 columns in sets of 3 across 2 rows?

Is there a way to arrange 6 columns in a grid so that the last 3 columns wrap onto a second row and all columns are centered? Specifically, I'm looking for a method to shift the first column by half the width of one column. <div class="row mx- ...

Clearly state the action of the form

I have utilized html, JavaScript, CSS, and JQuery to create a website template. Within this template, there is a file called contact.js that contains the ajax code for handling forms: $(function() { submitSuccess: function($form, event) { ...

Customizing the appearance of the dragged element in jQuery UI

Is there a way to modify the color of a draggable list item after it has been dragged? Any assistance is greatly appreciated. $("#DragWordList li").draggable({helper: 'clone'}); ...

Mysterious spectral division titled as a <div id="checkdv_1">

label appearing upon loading, the mysterious div lingering below my app div. I am not familiar with it and encountering it for the first time in my Vue project. I have checked extensions and attempted to search online to understand it, but no luck so far. ...

Resolving Anchor Problems in PHP

I'm struggling with a line of code and need some help: echo "<td>"<a href="userdetails.php?".$row[username].">View Details</a></td>"; When I try to create the link on a page, I want it to be in the format userdetails.php?USER ...

Flip-Card: Hrefs malfunctioning within card.flip

Currently, I am incorporating a flip-card building block from the Foundation CSS framework into my portfolio projects. However, I have encountered an issue with the two links placed on the back/inner side of each card - for some reason, the hrefs are not f ...

Filter AngularJS data based on checkboxes selected

I am facing an issue with a function I created to filter displayed data based on checkbox selection. Although the checkboxes are functioning properly, I am struggling to correctly push the selected checkbox value into the data for the desired output. http ...

What is preventing :host from expanding vertically with its content in Safari when using Angular 2?

I'm currently working on a project using Angular2 to develop a website. In the styling of my components, I am utilizing the :host selector. The CSS used for each component is very similar across the board: :host { position: relative; top: 60px; ...

Modify the CSS of one div when hovering over a separate div

I've been working on a simple JavaScript drop-down menu, and it's been functioning correctly except for one issue. When I move the mouse out of the div that shows the drop-down menu, it loses its background color. I want the link to remain active ...

Is it possible to rebind data on a RadCombobox using ajax?

Recently, I've been restructuring my workflow by utilizing a webservice to help me better organize things. This has made using AJAX much simpler and efficient for me. Currently, when a user wants to save a new contact, they are added to a database th ...

Creating a CSS full-width navigation menu

Recently, I came across a menu code on the web that seemed great. However, I wanted to make my menu responsive and full width. Since I am new to CSS and HTML, adjusting the menu code has been a bit of a challenge for me. .menu, .menu ul { list-style: ...

When using .animate() to set the position, it takes precedence over manually assigning

I'm facing an issue with constantly scrolling objects on the screen, each assigned a number. When you press one of their numbers, it should move far left off the screen and then scroll back on. However, when I try to reassign the position of the eleme ...

Issues with Display on IE 11 and Edge

Currently, I am in the process of working on a website that was initially created from a template by someone else. Since I am not a professional web designer, some elements on the site are not my own creation. Everything seems to be running smoothly on Fir ...

What steps should I take to adjust the CSS code to properly integrate with my HTML file?

There seems to be an issue with the code provided. The CSS for the menu bar is not functioning properly with the HTML. <!DOCTYPE html> <html> <body class="news"> <head> <style type="text/css">body { margin: 0; paddi ...

Nginx fails to load CSS in Asp.net Core on Raspberry Pi

First and foremost, thank you for taking the time to read my post. Secondly, I apologize for any language errors in advance. I am currently attempting to run an Asp.net core application on a Raspberry Pi, but I am encountering difficulties with nginx prox ...

What is the best way to eliminate a white border around an input button in an HTML document?

.KassTv{ position: absolute; top: -213px; left: -382px; display: inline-block; background-image: url("Images/KassTv.png"); } .KassTv:hover{ background-image: url("Images/LitTv.png"); } <form action="Home.htm"> <inp ...

Navigate to the element and retrieve a null offset

Currently, I am attempting to retrieve an element's ID from a select box and then scroll to that specific element using the following code snippet: // move to services $(function () { $("select.jump").change(function() { var selected = $( ...

"When setting up a window.EventListener, the Div element fails to be hidden when setting its display property to 'none

I'm working on creating a preloader by displaying an overlay until all the content on the page is loaded. However, despite checking my code multiple times, I can't seem to figure out why it's not working. If anyone could provide some assist ...