簡體   English   中英

字體大小增加和對比度/亮度,使用jquery對網站進行聲音控制

[英]Font size increase and contrast/Brightness,sound control of website using jquery

您好我的客戶有一個新的要求,他需要在他的網站中添加字體大小增加和對比度/亮度,聲音控制。

在此處輸入圖片說明

因此,在單擊該圖像上的任何圖像時,都會出現一個滑塊,並從中可以執行相應的操作。

在此處輸入圖片說明

我如何使用jquery做到這一點?首先,當單擊任何控件圖像時,我都需要像第二個圖像一樣出現“ +”,“-”滑塊。請提供幫助。

這是適合您的小型演示: http : //jsfiddle.net/GCu2D/692/

HTML:

<div>
    <ul>
        <li><a>Font</a>

            <div id="font" class="checked" data-min="8" data-max="100" data-step="1"></div>
        </li>
        <li><a>Brightness</a>

            <div id="brightness" class="checked" data-min="0" data-max="2" data-step="0.1"></div>
        </li>
        <li><a>Contrast</a>

            <div id="contrast" class="checked" data-min="8" data-max="100" data-step="1"></div>
        </li>
    </ul>
</div>
<div class="demo">Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum. It is a long established fact that a reader will be distracted by the readable content of a page when looking at its layout. The point of using Lorem Ipsum is that it has a more-or-less normal distribution of letters, as opposed to using 'Content here, content here', making it look like readable English. Many desktop publishing packages and web page editors now use Lorem Ipsum as their default model text, and a search for 'lorem ipsum' will uncover many web sites still in their infancy. Various versions have evolved over the years, sometimes by accident, sometimes on purpose (injected humour and the like). Contrary to popular belief, Lorem Ipsum is not simply random text. It has roots in a piece of classical Latin literature from 45 BC, making it over 2000 years old. Richard McClintock, a Latin professor at Hampden-Sydney College in Virginia, looked up one of the more obscure Latin words, consectetur, from a Lorem Ipsum passage, and going through the cites of the word in classical literature, discovered the undoubtable source. Lorem Ipsum comes from sections 1.10.32 and 1.10.33 of "de Finibus Bonorum et Malorum" (The Extremes of Good and Evil) by Cicero, written in 45 BC. This book is a treatise on the theory of ethics, very popular during the Renaissance. The first line of Lorem Ipsum, "Lorem ipsum dolor sit amet..", comes from a line in section 1.10.32. The standard chunk of Lorem Ipsum used since the 1500s is reproduced below for those interested. Sections 1.10.32 and 1.10.33 from "de Finibus Bonorum et Malorum" by Cicero are also reproduced in their exact original form, accompanied by English versions from the 1914 translation by H. Rackham. There are many variations of passages of Lorem Ipsum available, but the majority have suffered alteration in some form, by injected humour, or randomised words which don't look even slightly believable. If you are going to use a passage of Lorem Ipsum, you need to be sure there isn't anything embarrassing hidden in the middle of text. All the Lorem Ipsum generators on the Internet tend to repeat predefined chunks as necessary, making this the first true generator on the Internet. It uses a dictionary of over 200 Latin words, combined with a handful of model sentence structures, to generate Lorem Ipsum which looks reasonable. The generated Lore</div>

CSS:

ul {
    margin:0;
    padding:0;
    list-style-type:none;
    white-space:nowrap
}
ul li {
    display:inline-block;
    width:100px;
    padding:5px;
    font-size:12px;
    color:#000;
    position:relative
}
ul li .checked {
    position:absolute;
    top:100%;
    display:none;
    left:0;
}
ul li a {
    display:block;
}
.demo {
    margin-top:100px;
    color:#000;
    border:1px solid #bfbfbf
}

JS:

$(document).ready(function () {
    $("ul").on("click", "a", function () {
        $(this).next(".checked").toggle();
    });
    $(".checked").each(function () {
        $(this).slider({
            orientation: "vertical",
            min: 0,
            step: parseFloat($(this).attr("data-step")),
            max: parseInt($(this).attr("data-max")),
            slide: function (event, ui) {
                var value = ui.value;
                var type = $(this).attr("id");
                console.log(type)
                switch (type) {
                    case "font":
                        {
                            $(".demo").css("font-size", value + "px");
                            break;
                        }
                    case "brightness":
                        {
                            console.log(value);
                            $(".demo").css("background-color", "rgba(0,0,0," + value + ")");
                            break;
                        }
                    case "contrast":
                        {
                            //Your code
                            break;
                        }
                }
            }

        });
    })
});

資源鏈接: http : //api.jqueryui.com/slider/#event-slide

應該對您有所幫助。 只需單擊字體/亮度/對比度,將出現滑塊,然后可以設置值。

我認為該網站可能會對您有所幫助: http : //www.hongkiat.com/blog/jquery-volumn-slider/

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM