title: How to make the label of a slider translate in the X axis to fit the width of the slider using CSS?
body: <p>I want the label of the slider to translate in the X axis to fit the current width of the slider as I demonstrate in the <a href="https://media.giphy.com/media/Ytttd7RjoRL9YLVPT2/giphy.gif" rel="nofollow noreferrer">gif</a>. It is hard to explain what I want using words so please watch the gif to understand what I am trying to achieve.</p>
  <p>I already have the slider made up using material ui and react but I am not able to achieve the effect I showed in the gif.</p>
  <blockquote>
  <p>Here's the css I have for the slider right now:</p>
  </blockquote>
  <pre><code>:root {
    --slider-width: 60%;
  }
  
  .slider-container {
    margin: auto;
    position: absolute;
    left: 200px;
  
    bottom: 50vh;
    width: var(--slider-width);
    z-index: 999;
    padding: 10px;
  }
  
  span [class^=&quot;PrivateValueLabel-circle&quot;] {
    width: max-content !important;
    height: fit-content !important;
    transform: rotate(0deg) translateX(-35%) translateY(5px) !important;
    border-radius: 0% 0% 0% 0% !important ;
  }
  
  span [class^=&quot;PrivateValueLabel-label&quot;] {
    margin: 9px;
    transform: rotate(0deg) !important;
  }
  </code></pre>
  <blockquote>
  <p>Here is the code I used for the slider</p>
  </blockquote>
  <pre><code>import React, { useEffect, useState } from &quot;react&quot;;
  import Slider from &quot;@material-ui/core/Slider&quot;;
  import &quot;./app.css&quot;;
  
  const TextSlider = (props) =&gt; {
    const [value, setValue] = useState(-1);
    const [marks, setMarks] = useState([]);
  
    const handleChange = (event, newValue) =&gt; {
      if (newValue !== value) {
        setValue(newValue);
      }
    };
  
    useEffect(() =&gt; {
      setMarks([
        &quot;2020 trimestre 1&quot;,
        &quot;2020 trimestre 2&quot;,
        &quot;2020 trimestre 3&quot;,
        &quot;2020 trimestre 4&quot;,
        &quot;2021 trimestre 1&quot;
      ]);
      setValue(0);
    }, []);
  
    if (value === -1) {
      return &lt;div /&gt;;
    }
  
    return (
      &lt;div className=&quot;slider-container&quot;&gt;
        &lt;Slider
          aria-label=&quot;asdsds&quot;
          value={value}
          color=&quot;primary&quot;
          getAriaValueText={(value, index) =&gt; {
            return marks[value];
          }}
          valueLabelFormat={(value, index) =&gt; {
            return marks[value];
          }}
          aria-labelledby=&quot;discrete-slider-custom&quot;
          step={1}
          min={0}
          max={4}
          valueLabelDisplay=&quot;on&quot;
          onChange={handleChange}
          track={false}
          marks={true}
        /&gt;
      &lt;/div&gt;
    );
  };
  
  export default TextSlider;
  </code></pre>
  <p>Here's a condesandbox with the current slider that doesn't have the functionality I want to achieve: <a href="https://codesandbox.io/s/material-demo-forked-fd3m5?file=/app.css" rel="nofollow noreferrer">https://codesandbox.io/s/material-demo-forked-fd3m5?file=/app.css</a></p>