The alignment in the center is lacking consistency

Is anyone else experiencing issues with the duration and current time text not staying centered vertically? It seems to be a hit or miss, sometimes centering correctly and other times not. What could be causing this inconsistency, especially when no code changes have been made?

Check out this screenshot showing the problem: Not Working

And here's another screenshot after a hard refresh, where everything is suddenly aligned properly without any code alterations: Working

<div class="player-controls">
    <div>
        <button id="playpause-button">
            <i class="fas fa-play fa-lg"></i>
        </button>
    </div>
    <div class="time-container">
        <span id="currenttime">00:00</span>
    </div>
   ...
</div>

Take a look at the CSS style sheet below for reference:

.player-controls {
    background: #2f2f2f;
    display: block;
    padding: 0;
    margin: 0 auto;
    text-align: left;
    width: 840px;
    height: 52px;
    user-select: none;
}
...
#duration,
#currenttime {
    vertical-align: middle;
}

Answer №1

The reason for the confusion with vertical alignment is that the elements you are attempting to align are not directly adjacent to each other. To properly align these elements vertically, you should apply the vertical-align property to all elements within the player-controls container.

.player-controls > * {
    vertical-align: middle;
}

Answer №2

Following the suggestion of user "Sticker", I recommend adding the vertical-align:middle CSS property to the .player-controls button as shown below. You can see an example on Plunker here: https://plnkr.co/edit/tldchkIWflEDUFBQxZIw?p=preview

.player-controls button {
    background-color: Transparent;
    background-repeat:no-repeat;
    border: none;
    cursor:pointer;
    overflow: hidden;
    outline:none;
    color: #fff;
    vertical-align:middle;
}

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

Sometimes the Navbar options fail to show up consistently on the Navbar bar

I recently launched my website at campusconnect.cc Unfortunately, I've noticed that when resizing the window, the navbar options are shifting up and down. Can anyone help me identify the issue and provide guidance on how to resolve it? ...

Position the form / delete button in alignment with the rest of the buttons

I have a table with options at the end like View, Edit, and Delete. I need the Delete button to be inside a form so that I can POST the delete request. However, my button/form is not aligning on the same line as expected. I have tried using the form-inlin ...

Tips for creating a mandatory textarea input field

It's pretty straightforward - I have a textarea that is set to required, but it only alerts the user if you actually click inside the text area. If you try to submit without clicking inside, it won't prompt the alert. Take a look at this Fiddle ...

Fixing the Responsive Menu Issues

In order to achieve the desired effect of making the text from menu and logo disappear when minimizing the menu, you can use the following approach: Create a function called `smallNav()` to handle the resizing of the sidebar container: function sm ...

Exploring the Difference Between :nth-child(even|odd) and :nth-child(int) CSS Selectors

Encountering a challenge with the CSS :nth-child pseudo selector and suspecting that something crucial has been overlooked. index.html <html> <head>...</head> <body> <div class='selector'>first</di ...

Create a timer that plays music when a button is pressed

My goal is to initiate a timer when a specific button is clicked. While there are many timers available that start upon page load, I have not been able to find one that begins upon clicking a button. Additionally, the timer must start at the same time as ...

What is the best way to overlay my slider with a div containing content?

In the hero section of my website, there is a slider with 3 slides. I am looking to add a div element that will display content over these slides at all times, regardless of which slide is currently showing. ...

Show random images of different sizes by employing jquery

I am seeking a solution for my webpage which currently loads a random image from an array and centers it using negative margins in CSS. While this method works fine with images of the same size, I am looking to modify the code so that it can handle images ...

Achieving Text Centering in kableExtra Cells with CSS: A Step-by-Step Guide

Recently, I received a helpful solution that involved using the extra_css = argument in cell_spec() from the kableExtra package. This allowed me to fill the entire cell of my table instead of just the text inside it. However, even after specifying align = ...

Choose a specific portion of text following an element in HTML using CSS

I would like to style the text following the span tag using CSS without affecting the span tag itself. Specifically, I want to apply styling only to the text that reads "Text to be selected", leaving the span tag unaffected. The style I desire i ...

Setting the column width and border-top in Highcharts

Hey there, I'm facing an issue with my highcharts diagram. 1) Can anyone help me adjust the column width to match the width of the month area? (I've tried changing "width" in CSS but it's not working) 2) Also, how can I remove all borders ...

"Challenges in styling a table within a div: the text fails to adhere to the

I am struggling to identify the source of a problem in my code. The issue seems to be related to the padding within the parent div, specifically with the text "1 Healthy Midday Meal for One Child Overseas" and how it is ignoring the 5px right padding. Upon ...

Integrating the Google Translate tool onto a website

My goal is to integrate a translation tool like Google Translator or other reliable options onto my website. I am not looking to translate the entire content of my pages into another language, but instead want to add a feature similar to the one found on t ...

"Enhance Your CSS Styling with an Additional Dot for Dotted Under

Is it possible to make the dots at the end and sometimes beginning of a word thicker and more round? https://i.stack.imgur.com/W9WPi.png ' CODE <span style="border-bottom: 3px dotted #111;">Personal Project Magazine Ads Personal Project Magaz ...

Stylish dots emerging under navigation bar

Okay, so I've run into a simple issue, but I can't seem to figure out the solution. Ever since I wrote this code, I've noticed these small dots appearing below the menu. Take a look at the image for a clearer picture. https://i.sstatic.ne ...

There seems to be a glitch with the Flask flash messaging feature, as

My Flask application includes login and register routes where I aim to display flash messages when username passwords are not matched. Specifically, this issue arises in my index and login routes: @app.route('/') @login_required def index(): ...

Tips for showcasing a search bar on Google search results

While browsing in Google, I came across websites that have a search bar displayed after their initial search result. This functionality allows users to easily search within the website as shown in the image below. I am intrigued and wondering how this can ...

Determine the value of a checkbox as 0 if unchecked and 1 if checked

How can I retrieve a value of 1 when a checkbox is checked and 0 when it is unchecked? <input type="checkbox" name="data[color][]" class="color" value="1" checked> The data array stores information from in ...

When the label is clicked, retrieve the value of the checkbox within

I have a checkbox inside a label, and for design purposes, I added a div there. My requirement is to get the checkbox value on the click event of the label. However, I am always getting false whenever the checkbox is clicked. <label class="text-xs col- ...

Creating a visually appealing table in HTML or experimenting with a tableless design can greatly enhance your website's layout

Presenting data with headers in HTML has been a challenge for me. Below is the portion of the header I'm having difficulty with. Although I've successfully rotated the text, the issue I'm facing now is text overlap. Here's the code st ...