HTML and CSS: creating a loading progress bar with a buffer

Could someone assist me in adjusting the CSS and/or HTML for my loading bar? I am currently facing two issues with it.

The first problem is that there seems to be an excess shadow extending outside the bar on the left and right beyond the border. This gives the appearance of pixelation in the border-radius when properly zoomed in. It seems to be related to the box-shadow property, as removing it from both #progress and #buffer eliminates the issue.

The second issue is relatively minor but quite irritating. When the progress/buffer bar begins to load (with a width of 0.4%), the shape of the div exceeds the container:

I understand that I can use overflow:hidden (which I already use in #loading_bar_container) to address this, but it seems that setting position:absolute prevents it from being hidden (and I require absolute positioning to ensure the two bars overlap each other). If I remove #buffer (leaving just one bar) and eliminate position:relative from #loading_bar and change position:absolute to absolute in #progress, I achieve the desired layout:

Here is a piece of code from a JSFiddle snippet where we can experiment with it further.

Cheers!

PS: I believe the tag should be 'loading-bar,' but since I cannot create a new tag, I appended it as 'progress-bar.'

Edit: After testing in Chrome, @Oriol mentioned that it functions well in Firefox. Upon checking, Firefox displays it correctly as intended. I also verified Safari, which exhibits similar behavior to Chrome. Therefore, this inquiry pertains to Chrome and Safari specifically. I have not tested it in IE yet (feeling hesitant).

Answer №1

There appears to be a bug in Chrome related to the position:relative property.

Take a look at the examples here: http://jsfiddle.net/VeJNt/2/ and http://jsfiddle.net/VeJNt/3/

Instead of using position:relative and position:absolute, you can try this:

#progress {
    margin-top:-8px;
}​

Check out the updated version here: http://jsfiddle.net/VeJNt/4/

Consider simplifying your code by removing redundant elements like loading_bar_container and loading_bar: http://jsfiddle.net/VeJNt/5/

Note:

If you want a more flexible code that works regardless of the number of bars, you can use the following CSS:

#loading_bar>div {
  border-radius:7px;
  height:100%;
  width:0%;
  margin-top:-8px;
}
#loading_bar>div:first-child {
  margin-top:0;
}

You only need to adjust the background and box-shadow properties for each bar individually.

View the enhanced version here: http://jsfiddle.net/VeJNt/6/

Remember, when setting negative margins, subsequent elements also move accordingly. You don't need to keep increasing the negative margin for each element as they will adjust automatically based on the previous one's positioning.

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

Diverse outcomes generated by a single dropdown selection - Harnessing the power of JavaScript and HTML

I am seeking a way to dynamically show different sections of my form based on the selection made from a drop-down menu. Currently, I am facing two issues: it only hides the first area I want hidden, and I am struggling with the syntax to make multiple opt ...

Error encountered: The property indexOf cannot be read. Possible issue with .load() function in jQuery causing this error

https://i.sstatic.net/R7zUX.png As I navigate through the page and interact with different elements, I encounter an error message. The Obj function, which is responsible for setting a property value in an object from a handlebars template input and loadi ...

Is it necessary to include the 'html' and 'body' tags in a WordPress Page Template?

Currently, I'm in the process of creating a unique Page Template for my WordPress website. In the file named newpagetemplate.php, I have included only this code: <html> <body> <?php /* Template Name: CustomPage */ ?> <div> ...

Having difficulties with incrementally rotating a CSS cube to every direction

Can anyone help me with rotating a cube one side at a time using CSS? I can make the cube rotate to the top / bottom and each side correctly, but when I try to rotate to the top or bottom first and then to a side, the cube spins without rotating left or ri ...

The upper border is missing from the middle div in the presence of three divs

I am currently working on a new project using HTML, CSS, and Bootstrap. However, I have encountered a problem. I have created a box with a border all around it, and when I hover over this box, an image appears inside of it. By default, the inside of the bo ...

How can I effectively develop a versatile user interface for a website using Ruby on Rails that is compatible with all

Currently, I am in the midst of developing a web application using Ruby on Rails. Occasionally, I encounter challenges with cross-browser compatibility when it comes to CSS and Javascript. Are there any strategies you recommend to reduce these issues dur ...

How can I arrange individual events in agendaWeek view on FullCalendar.io and then merge them all into one line?

I am using Fullcalendar.io version 2 When I switch to the agendaWeek mode, all my events are displayed on one line in each day square. As a result, the more events I have, the thinner the event blocks become. Is there a way for me to display only one eve ...

What is the best way to design an HTML table that features alternating colors for each row and column?

I recently came across this image showcasing a beautifully designed table: https://i.stack.imgur.com/6K63q.png The current HTML code I have applies colors to every even line, including the year columns and subcolumns. Is there a way to assign unique mixe ...

Transferring HTML elements between pages

I'm currently working on a project with 4 tabbed views, each housed in separate HTML pages. Each view contains several SVG charts created using d3.js. Now, the client wants to be able to easily cut, paste, or move charts from one tabbed view to anothe ...

Steps for creating a file selection feature in Chonky.js

I recently integrated the Chonky library into my application to build a file explorer feature. One challenge I am facing is figuring out how to select a file and retrieve its unique ID when the user double clicks on it. const [files, setFiles] ...

Mobile Image Sizing with Bootstrap 4 Cards

I am currently developing a responsive web application using Bootstrap 4 and incorporating cards with images on one of the pages. The layout functions properly when resizing the window on desktop view; however, upon viewing it on mobile devices, I noticed ...

Guide on how to have two controllers execute identical tasks in Angular while modifying the appearance of the website

Trying to recreate Google's homepage functionality using Angular has been challenging for me. Despite watching Egghead videos and studying the API extensively, I couldn't find a specific example for this behavior. Here's what I aim to achiev ...

Tips for adjusting jCountdown timer to be auto responsive while utilizing CSS sprite resources

The jCountdown plugin creates stunning effects that can be viewed at: After inspecting the resources, it appears that the plugin uses css sprite animation to achieve its effects. I am curious about how challenging it would be to make it responsive and avo ...

`CSS border issues`

I am currently attempting to create a square consisting of 4 smaller squares inside, but I have been facing challenges with the method I was using. Here is the code snippet: #grandbox { position: absolute; width: 204px; height: 204px; border: so ...

Creating interactive tooltips in Shiny applications with the help of ShinyBS

I am attempting to incorporate the shinyBS package into my basic app. My goal is to generate dynamic tooltip text based on each radioButton selection. To better illustrate my issue, I have drafted a simple code snippet in HTML & JS. While I came acro ...

If the text width of a label exceeds the total width of its container, intelligently display a sub-string based on pixel calculations

I am looking to shorten the text inside a label if its width exceeds the total width of its container. Instead of displaying the full text, I want to display a sub-string of it. if (SensorType.Text.Length >= 25) { SensorType.Text = SensorType.Text ...

CSS code to create a single content bar flanked by two sidebars

I have been working on a beginner-friendly webpage and have managed to style it using CSS to some extent. My goal is to have the content centered with a white background, flanked by two sidebars styled in blue. To work on this page, please visit: The ...

Font family experiencing compatibility issues with font face

The prominent "C" at the center of the page, as well as the H1 ('Choose The Right...) should be displayed using the "Pirulen" font-family. My initial attempt was to implement the traditional @font-face method for CSS, followed by a more advanced appr ...

Jumbling a word by shuffling its letters into a random order

The objective of the program is to take the word you input into a box, split it into an array of letters, and then shuffle them. Following that, it should capitalize the first letter and lowercase the rest before displaying the result in the same box. I a ...

Customize the MUI Slider Component with unique colored thumbs

Check out MUI's slider component at this link. I'm using it to let users select a value range with two thumbs. You can find the documentation for MUI's multi-thumb slider here. If you want to customize the style of the slider thumb, visit ...