TobiasW
TobiasW

Reputation: 891

How to get a label between the jqm rangeslider and the sliderthumb?

I want my label between the slider and the slider thumb, so that I can save as much screen space as possible. Now is my problem, that the label is above everything and I cant't fix it with z-index...

HTML:

<div class="container">
    <div class="slider">
        <label for="slider1" class='sliderlabel'>Test</label>
        <input type="range" id='slider1' min="0" max="100" data-role="none">
    </div>
</div>

CSS:

.sliderlabel {
    z-index: 1;
    color: white;
    left: 35%;
    position: absolute;
}

input[type="range"]::-webkit-slider-thumb {
    z-index: 2;
    -webkit-appearance: none !important;
    width: 20px;
    height: 20px;
    background-color: #579e81;
    border-radius: 30px;
    /*    box-shadow: 0px 0px 3px #3c6d59;*/
    transition: all 0.5s ease;
}

A full example of my code is here : http://jsfiddle.net/bjvDB/3/

Upvotes: 1

Views: 48

Answers (1)

CMurlowski
CMurlowski

Reputation: 73

Try it this way:

CSS:

    .label {
        position: absolute;
        margin-top: 10px;
        margin-left: 100px;
        z-index: 2;
    }
    #slider1 {
        position: relative;
        z-index: 1;
    }
    .ui-btn {
        z-index: 3!important;
        background-color: red!important;
    }

HTML:

 <div data-role="page">
        <div data-role="content">
            <div class="label">
                TEST
            </div>
            <div>
                <input class="slider" type="range" value="0" min="0" max="100" id="slider1" step="5" />
            </div>

        </div>
    </div>

http://jsfiddle.net/cq69z/

Upvotes: 1

Related Questions