0

I'm trying to style a meter element, and the traditional webkit solution works in Chrome, but doesn't seem to be working in Safari.

.my-box{
    border: 1px solid indigo;
        width: 200px;
    height: 100px;
    position: relative;
    overflow: hidden;
}
.my-box .meter {
    width: 200px;
    height: 20px;
    position: absolute;
    bottom: -6px;
}
.my-box .meter::-webkit-meter-bar {
    background: lavender;
    border: none;
}

.my-box .meter::-webkit-meter-optimum-value {
    background: rebeccapurple
}
<div class='my-box'>
    <meter class='meter' min='0' max='1000' value='700'></meter>
</div>

result in chrome: enter image description here

result in safari: enter image description here

Link to codepen.

MaxiGui
  • 6,190
  • 4
  • 16
  • 33
NbonD
  • 317
  • 6
  • 17
  • Check this: https://stackoverflow.com/questions/38622911/styling-meter-bar-for-mozilla-and-safari – MaxiGui Oct 01 '20 at 10:52

2 Answers2

0

Found the media query that allows me to target safari, and set the meter appearance to none, then my styles can override default styles:

@media not all and (min-resolution:.001dpcm) { 
    @media {
        .my-box .meter {
            -webkit-appearance: none;
            appearance: none;
        }
    }
}

codepen updated

NbonD
  • 317
  • 6
  • 17
0

I found a solution: you can set the border property of the meter element to 0 (border: 0;) and suddenly it works in Safari as well. I lost almost a day to find this solution :-)

https://codepen.io/receter/pen/abqWjEN

.my-box{
    border: 1px solid indigo;
    width: 200px;
    height: 100px;
    position: relative;
    overflow: hidden;
}

.my-box .meter {
    width: 200px;
    height: 20px;
    position: absolute;
    bottom: -6px;
    border: 0;
}

.my-box .meter::-webkit-meter-bar {
    background: lavender !important;
    border: none;
}

.my-box .meter::-webkit-meter-optimum-value {
    background: rebeccapurple
}
Andreas Riedmüller
  • 1,217
  • 13
  • 17