HTML5 progress bar "ending" styling - html

I want to style the "ending" of the current progress of the HTML5 progress bar by adding small black dot to it, see the screen. So this dot must move as progress moves
But the code I found here doesn't work anymore. It worked few weeks ago or so, but now it's not - see the codepen
Maybe someone knows what happened or how to achieve my goal?
Thanks a lot!
P.S. Here is the HTML/CSS I use
HTML:
<progress value="1400" max="4261"></progress>
CSS
progress {
/* Positioning */
position: absolute;
left: 0;
top: 0;
/* Dimensions */
width: 100%;
height: 50px;
/* Reset the appearance */
-webkit-appearance: none;
-moz-appearance: none;
appearance: none;
/* Get rid of the default border in Firefox/Opera. */
border: none;
/* Progress bar container for Firefox/IE10+ */
background-color: transparent;
/* Progress bar value for IE10+ */
color: #00D38D;
}
progress[value]::-webkit-progress-value {
position: relative;
background: #00d38d;
}
progress[value]::-webkit-progress-value::after {
content: '';
width: 20px;
height: 20px;
position: absolute;
right: 10px;
top: 15px;
border-radius: 50px;
background: black;
}
progress::-webkit-progress-bar {
background-color: transparent;
}
progress::-webkit-progress-value {
background-color: #00D38D;
}
progress::-moz-progress-bar {
background-color: #00D38D;
}

You don't need a pseudo element to get this effect. Here it is using a gradient on the main style. (Tested only in Chrome)
progress {
/* Positioning */
position: absolute;
left: 0;
top: 0;
/* Dimensions */
width: 100%;
height: 50px;
/* Reset the appearance */
-webkit-appearance: none;
-moz-appearance: none;
appearance: none;
/* Get rid of the default border in Firefox/Opera. */
border: none;
/* Progress bar container for Firefox/IE10+ */
background-color: transparent;
/* Progress bar value for IE10+ */
color: #00D38D;
}
progress::-webkit-progress-value {
background-image: radial-gradient(circle at calc(100% - 30px) center, black 15px, lightgreen 15px);
}
progress::progress-value {
background-image: radial-gradient(circle at calc(100% - 30px) center, black 15px, lightgreen 15px);
}
<progress value="1400" max="4261"></progress>

I read here that the pseudo css appears not to work with the progress element:
I wish that I could have used :after (or ::after) rules instead, but
these pseudo-elements don’t work with the progress tags in any browser
that doesn’t use the polyfill. And no, :before doesn’t work either. I
have no idea why it doesn’t work, but it’s a shame — using them would
be perfect to get rid of the extra markup.
Found here: http://www.useragentman.com/blog/2012/01/03/cross-browser-html5-progress-bars-in-depth/
I'm not sure why it was working before, I haven't been able to find a non JS way to emulate the effect of using the ::after css.
Here's a codepen from that article you referenced where it's not working as well.
They appear to be using the same method as you and it has no function:
progress[value]::-webkit-progress-value:after {
/* Only webkit/blink browsers understand pseudo
elements on pseudo classes. A rare phenomenon! */
content: '';
position: absolute;
width:5px; height:5px;
top:7px; right:7px;
background-color: white;
border-radius: 100%;
}
You may have to implement some sort of javascript or use a different method other than the HTML5 progress element to implement this.
Numbars has some similar stuff to what you're trying to do, but you may need to modify it a decent amount to get it functioning the way you want.
Sorry this isn't exactly a solution, but hopefully you can find a workaround that's not too tough to create.

Related

How to use inverted border-radius? [duplicate]

This question already has answers here:
Invert rounded corner in CSS?
(10 answers)
Closed last year.
I giving an indicator to menu items using border property and I want it to be rounded backwards as in the image below:
I tried using border-radius but this is the result:
Also feel free to suggest different approaches for implementing an indicator for sidebar menus in react since I'm not sure if this is possible using css properties.
Just use before and add an element to style
div {
position: relative;
display: inline-block;
background-color: blue;
width: 10em;
height: 10em;
}
div::before{
display: block;
position: relative;
content: '';
width: 10%;
top: 15%;
height: 70%;
background-color: white;
border-top-right-radius: 1em;
border-bottom-right-radius: 1em;
}
<div></div>
Try using CSS-Tricks' Infinite Borders technique and applying border-radius. This method will require borders and box-shadow and not outline.
img { border-radius: 4px;
/* #1 */ border: 5px solid hsl (0, 0%, 40%);
/* #2 */ padding: 5px; background: hsl (0, 0%, 20%);
/* #3 outline: 5px solid hsl (0, 0%, 60%);
*/ /* #4 AND INFINITY......!!!
Mate, Atleast post your code with the question so that people can help you and advise you how to correct it.
P.S - I know this belongs in the comment and not an answer but I am new to Stack Overflow and I don't have points to comment on anything

z-index not working as expected on hovered side nav

I have sample page here: https://jsfiddle.net/solaris_9/17dwfmap/16/
.area-toc a {
position: absolute; /* Position them relative to the browser window */
left: -120px; /* Position them outside of the screen */
transition: 0.3s; /* Add transition on hover */
/*padding: 2px; *//* 15px padding */
width: 140px; /* Set a specific width */
text-decoration: none; /* Remove underline */
font-size: 15px; /* Increase font size */
color: white; /* White text color */
border-radius: 0 2px 2px 0; /* Rounded corners on the top right and bottom right side */
text-align: center;
background-color: #76a000;
z-index: 99;
}
.area-toc a:hover{
left: 0;
z-index: 99;
}
.table-main{
border-style:solid;
border-color:#aad69e;
border-width:1px 1px 1px;
z-index:9;
position:relative;
}
Generally speaking, when the mouse hovers at the side nav, I want the link could be rendered in front of the table. I set the z-index of it to 99, while the table is 9, but it doesn't work.
Do you have any idea? Does it link to the flex display of the table?
This is a problem I often face too when working with z-index's. The way I workaround this is to just set the z-index of the element I want to be lower, to a negative number.
https://jsfiddle.net/17dwfmap/27/
On line 113, I changed
z-index:9;
to
z-index:-10;

How can i create complex background shape using CSS and HTML ( Example image added in the description )

I am working on a project which has a custom shape background and an image on top of it. Its located on the Hero area of the landing page. I need a good solution so that the custom shape will be in the background. And the user can change the image or the Color if they needed.
Here is a demo of the shape I am talking about. Is there any way I can achieve it using CSS, and the user can change the image or color later? What do you think of a solution here?
Thanks in advance.
This is actually multiple questions.
How can I layer multiple elements over each other.
How can I change the shape of an html element.
The now deleted answer by Alexandre Beaudet, that you said was 'Not really close to what I wanted', actually did answer the second question clearly and briefly. You were too blinded by the details of what you want to see the principle you needed to learn from that answer.
Given how easy these elements are to research, I don't even want to show you example code, but here's one:
.wrapper {
width: 100%;
height: 300px;
background: gray;
position: relative;
}
.background-shape {
background: orange;
width: 100%;
height: 200px;
-ms-transform: skewY(-20deg);
-webkit-transform: skewY(-20deg);
transform: skewY(-20deg);
border-radius: 30px;
position: absolute;
top: 0px;
left: 50px;
}
.content {
color: white;
position: absolute;
top: 120px;
left: 30%;
z-index: 10;
}
<div class="wrapper">
<div class="content">
Lorem Ipsum Hero
</div>
<div class="background-shape">
</div>
</div>
This is EXAMPLE code. SO is not a copy-paste solution site. It is here to teach you specific mechanisms you were heretofore unaware of to solve specific problems. It just so happens that code snippets can be one of the best ways to explain things in a succinct and clear way.
To implement this on your website you will need to put a LOT of work into this to position and shape everything so that it actually looks good on all devices.
I was finally able to solve this problem on the day I posted it on StackOverflow. Thanks to all the guys who have commented. I used a CSS pseudo element to make this shape.
Here is my code.
// Header Shape
.has-header-shape {
position: relative;
&::before {
position: absolute;
width: 1350px;
height: 550px;
content: "";
background: #0cebeb; /* fallback for old browsers */
background: -webkit-linear-gradient(
to right,
#8cbf86,
#66b4a6,
#408ca3
); /* Chrome 10-25, Safari 5.1-6 */
background: linear-gradient(
to right,
#8cbf86,
#66b4a6,
#408ca3
); /* W3C, IE 10+/ Edge, Firefox 16+, Chrome 26+, Opera 12+, Safari 7+ */
z-index: -1;
top: 0px;
border-radius: 60px;
-webkit-transform: skew(0deg, -15deg);
transform: skew(0deg, -15deg);
left: auto;
right: 0;
}
}

How to select a button beside the gradient filter

I met a project that set the gradient filter to whole web page.
So I have implemented the filter like this.jsfiddle
HTML
<div class="container">
<button class="tag">Featured</button>
<div id="grad1">
</div>
CSS
#grad1 {
height: 200px;
background: red; /* For browsers that do not support gradients */
background: -webkit-linear-gradient(red, yellow); /* For Safari 5.1 to 6.0 */
background: -o-linear-gradient(red, yellow); /* For Opera 11.1 to 12.0 */
background: -moz-linear-gradient(red, yellow); /* For Firefox 3.6 to 15 */
background: linear-gradient(red, yellow); /* Standard syntax (must be last) */
opacity: 0.5;
}
.container {
border: 1px solid #DDDDDD;
width: 200px;
height: 200px;
position: relative;
}
.tag {
float: left;
position: absolute;
left: 0px;
top: 0px;
background-color: #92AD40;
padding: 5px;
color: #FFFFFF;
font-weight: bold;
}
But the problem is button is not selectable in this case.
I have no sense how to make the button work.
How can I make button selectable and also show gradient above the button?
Finally UI should look like this.
its seems you are looking for pointer-events: none;
Demo http://jsfiddle.net/r6tdc3Lh/5/
a </div> tag is missing.
At the end of ur code.
Ur container isnt closing, so your button cant‘t be clicked.
Try to add just another closing tag.
Check the fiddle. You have two issue 1. set button attribute type="button" and 2. .tag z-index should be 1. Because your button is absolute position.
UPDATE
I Update the fiddle. I think it will help you.

Issue related to Background-Position for Image in HTML in CSS

I have following CSS class :
.acceptRejectAll a, .acceptRejectAll a:visited{
background-image: url("../images/view-patient.png");
background-position: left top;
background-repeat: no-repeat;
color: #4B555C;
float: left;
height: 35px;
padding-top: 12px;
text-align: center;
text-decoration: none;
width: 100px;
}
and following HTML :
<div style="float: none; display: inline-table" class="acceptRejectAll">
<a style="display:inline-block;height:25px;" href="#" class="fontBlack" id="ctl00_ContentPlaceHolder1_btnAcceptAll">Accept All</a>
</div>
this is display as follows :
when i decrease the size of in css class like : width : 85px
it displays as follows :
it cuts image from right side:
i tried to set background-Position in css class : but either left side or right side, image is not display correctly
wht is solution ?
Thanks
You will need to use background-size for this. Example:
background-size: 100% 100%;
Please note that this setting can scale your image to fill parent.
As the image is 100px (at least the visible part is about 92px so I guess the size is 100px) if you change the size of the button you need to scale the background image rather than change the position.
background-size:85px 35px;
Gradient and Border radius
Another way to approach this — considering the kind of button style you are using — is to go the gradient and border radius route. Whilst the code to use a css gradient looks rather messy, it is dynamically generated so you wont end up with stretched curved corners like you will using background-size.
Everything used below is pretty well supported now by most browsers. For anything that doesn't support the gradient you will get a solid blue background with curved corners instead, and it almost isn't worth worrying about non-support for border radius any more.
markup:
<div class="acceptRejectAll">
Accept All
</div>
css:
.acceptRejectAll {
display: inline-table;
border-radius: 20px;
text-align: center;
padding: 10px;
width: 100px; /* You can change the width as you like */
background: #c3e5fe; /* Old browsers */
background: -moz-linear-gradient(top, #c3e5fe 0%, #98d1fd 100%); /* FF3.6+ */
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#c3e5fe), color-stop(100%,#98d1fd)); /* Chrome,Safari4+ */
background: -webkit-linear-gradient(top, #c3e5fe 0%,#98d1fd 100%); /* Chrome10+,Safari5.1+ */
background: -o-linear-gradient(top, #c3e5fe 0%,#98d1fd 100%); /* Opera 11.10+ */
background: -ms-linear-gradient(top, #c3e5fe 0%,#98d1fd 100%); /* IE10+ */
background: linear-gradient(to bottom, #c3e5fe 0%,#98d1fd 100%); /* W3C */
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#c3e5fe', endColorstr='#98d1fd',GradientType=0 );
}
.fontBlack {
font-family: sans-serif;
font-size: 10pt;
color: black;
text-decoration: none;
}
The gradient was generated using:
http://www.colorzilla.com/gradient-editor/#c3e5fe+0,98d1fd+100;Custom
You end up with:
http://jsfiddle.net/NDHtn/
Or as a preview:
When you must use an image
If there is no other choice but to use an image as a background for a button — say, the graphics are too complicated to replicate using css effects — rather than use one image stretched and distorted to fit, you can use something like the following. There are many ways to essentially achieve the same result, I prefer to keep my mark-up simple and my css more complicated (rather than the other way around). However, to make things more supportive of the wider browser community you can break your mark-up into three parts, rather than make use of ::before and ::after:
markup:
<a class="button" href="#">
<span>Round Button with lots of text and then some</span>
</a>
css:
.button:before {
position: absolute;
content: '';
background: url('image.png') left top;
top: 0;
left: -50px;
width: 50px;
height: 99px;
}
.button:after {
position: absolute;
content: '';
background: url('image.png') right top;
top: 0;
right: -50px;
width: 50px;
height: 99px;
}
.button {
background: url('image.png') center -99px;
height: 99px;
margin: 0 50px;
position: relative;
display: inline-block;
color: white;
text-decoration: none;
}
.button span { display: block; padding: 35px 0px; }
image.png, hacked together using this original image and pixlr.com:
Which will give:
http://jsfiddle.net/2K5Kg/1/
Example mark-up without use of psuedo elements:
<a class="button" href="#">
<span class="before"></span>
<span class="after"></span>
<span>Round Button with lots of text and then some</span>
</a>
Then in the css just replace the .button:before with .button .before and the same for :after.