我正在尝试使用适用于jQuery可调整大小/可拖动的工作范围输入滑块。我知道这里有熟悉的问题和解决方案,但它们不符合我的需求。我遇到的问题是,在调整字段大小时,我希望滑块沿东西方向均匀调整大小。并且由于某些原因,数字不会显示。对于如何解决这个问题,有任何的建议吗?在此之前,我不得不说这是代码世界中每个人的最佳资源,我非常感谢您的帮助。谢谢。
$(function() {
$(".field-wrapper").draggable({
handle: ".handle"
})
.resizable({
handles: "all",
resize: function(e, ui) {
var s = ui.size;
$(".field", this).width(s.width - 40).height(s.height);
$(".handle", this).height(Math.round(s.height / 2) + 20).css("margin-top", (Math.round(s.height / 2) - 20) + "px");
}
});
});
.field-wrapper {
width: 245px;
border: 2px inset #ccc;
border-radius: 26px;
padding: 0;
}
.field-wrapper .handle {
display: inline-block;
cursor: move;
}
.field-wrapper .field {
border: 0;
padding: 0;
padding-left: .5em;
margin: -1px 0;
border-left: 1px solid #ccc;
height: 5em
}
input[type='range'] {
box-sizing: border-box;
border: 0px solid transparent;
padding: 0px;
margin: 0px;
width: 210px;
height: 50px;
cursor: pointer;
background: -webkit-repeating-linear-gradient(90deg, #777, #777 1px, transparent 1px, transparent 40px) no-repeat 50% 50%;
background: -moz-repeating-linear-gradient(90deg, #777, #777 1px, transparent 1px, transparent 40px) no-repeat 50% 50%;
background: repeating-linear-gradient(90deg, #777, #777 1px, transparent 1px, transparent 40px) no-repeat 50% 50%;
background-size: 122px 25px;
font-size: 16px;
}
input[type='range'],
input[type='range']::-webkit-slider-runnable-track,
input[type='range']::-webkit-slider-thumb {
-webkit-appearance: none;
}
input[type='range']::-webkit-slider-runnable-track {
box-sizing: border-box;
width: 200px;
height: 5px;
border-radius: 2px;
background: #777;
}
input[type='range']::-moz-range-track {
box-sizing: border-box;
width: 200px;
height: 5px;
border-radius: 2px;
padding: 0px;
background: #777;
}
input[type='range']::-moz-range-thumb {
box-sizing: border-box;
padding: 0px;
height: 20px;
width: 10px;
border-radius: 2px;
border: 1px solid;
background: #EEE;
}
input[type='range']::-ms-track {
box-sizing: border-box;
width: 210px;
height: 5px;
border-radius: 2px;
padding: 0px;
background: #777;
color: #777;
}
input[type='range']::-webkit-slider-thumb {
box-sizing: border-box;
padding: 0px;
height: 20px;
width: 10px;
border-radius: 2px;
border: 1px solid;
margin-top: -8px;
background: #EEE;
}
input[type='range']::-ms-thumb {
box-sizing: border-box;
padding: 0px;
height: 20px;
width: 10px;
border-radius: 2px;
border: 1px solid;
background: #EEE;
}
input[type="range"]::-ms-fill-lower {
background: transparent;
}
input[type='range']:focus {
outline: none;
}
.field-wrapper rangeinput:after {
position: absolute;
color: #777;
content: '20 40 60 80';
padding: 40px;
word-spacing: 20px;
left: 0px;
top: 0px;
z-index: -1;
}
.field-wrapper rangeinput {
padding: 0px;
position: relative;
}
.field-wrapper rangeinput output{
display: block;
margin-top: 20px;
color: #777;
}
.field-wrapper rangeinput output:before{
content:"Selected Value: ";
font-weight: bold;
}
.field-wrapper rangeinput body {
font-family: Calibri, Arial;
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<link rel="stylesheet" href="//code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css">
<script src="https://code.jquery.com/jquery-1.12.4.js"></script>
<script src="https://code.jquery.com/ui/1.12.1/jquery-ui.js"></script>
<div class="field-wrapper">
<span class="handle ui-icon ui-icon-grip-dotted-vertical"></span>
<input type="range" min="0" max="100" value="50" step="1" list="tickmarks" id="rangeInput" oninput="output.value = rangeInput.value">
<datalist id="tickmarks">
<option value="0 to 20">0</option>
<option>20</option>
<option>40</option>
<option>60</option>
<option>80</option>
<option>100</option>
</datalist>
</div>
答案 0 :(得分:0)
要在调整大小时始终将中间对齐,您需要设置list = [https://hackerone.com, https://hackerone.com/hacktivity]
for url in list:
get_response = requests.get(url)
get_text = get_response.text
js_found = re.findall('"(.+?).js"', get_text)
#We mantain the hostname
host = url.split('/')
host_protocol = host[0]
host_name = host[2]
final_host = host_protocol + '//' + host_name
for i in range (len(js_found)):
#We add the .js that was removed at the regex
js_found[i] = js_found[i] + '.js'
if 'http' not in js_found[i]:
js_found[i] = final_host + js_found[i]
print(js_found)
for js in js_found:
js_response = requests.get(js)
print('===============================================================')
if "Not Found" in js_response.text:
print(js_response.text)
,然后设置上下左右偏移量
试试这个:(我还固定显示当前滑块值和水平问题)
position:absolute
$(function() {
$(".field-wrapper").draggable({
handle: ".handle"
})
.resizable({
handles: "all",
resize: function(e, ui) {
var s = ui.size;
$(".field", this).width(s.width - 40).height(s.height);
$(".handle", this).height(Math.round(s.height / 2)).css("top", (Math.round(s.height / 2)-5) + "px");
}
});
});
$("#rangeInput").on("change", function(){
$("#amount").html(this.value);
});
.field-wrapper {
max-width: 1300px;
border: 2px inset
#ccc;
border-radius: 26px;
padding: 0;
display: block;
position: relative;
left: 33px;
top: 44px;
height: 112px;
width: 254px;
min-height: 50px;
}
.field-wrapper .handle {
display: inline-block;
cursor: move;
top:40%;
}
.field-wrapper .field {
border: 0;
padding: 0;
padding-left: .5em;
margin: -1px 0;
border-left: 1px solid #ccc;
height: 5em
}
#amount
{
font-weight:bold;
text-align: center;
display: block;
position: absolute;
top: 10%;
left: 0;
right: 0;
}
input[type='range'] {
box-sizing: border-box;
border: 0px solid
transparent;
padding: 0px;
margin: 0px;
width: 90%;
height: auto;
cursor: pointer;
background: -webkit-repeating-linear-gradient(90deg, #777, #777 1px, transparent 1px, transparent 40px) no-repeat 50% 50%;
background: -moz-repeating-linear-gradient(90deg, #777, #777 1px, transparent 1px, transparent 40px) no-repeat 50% 50%;
background: repeating-linear-gradient(90deg,
#777, #777 1px, transparent 1px,
transparent 40px) no-repeat 50% 50%;
background-size: auto;
background-size: 122px 25px;
font-size: 16px;
position: absolute;
top: 40%;
bottom: auto;
right: 0;
margin: 0px auto;
left: 0;
}
input[type='range'],
input[type='range']::-webkit-slider-runnable-track,
input[type='range']::-webkit-slider-thumb {
-webkit-appearance: none;
}
input[type='range']::-webkit-slider-runnable-track {
box-sizing: border-box;
width: 200px;
height: 5px;
border-radius: 2px;
background: #777;
}
input[type='range']::-moz-range-track {
box-sizing: border-box;
height: 5px;
border-radius: 2px;
padding: 0px;
background: #777;
}
input[type='range']::-moz-range-thumb {
box-sizing: border-box;
padding: 0px;
height: 20px;
width: 10px;
border-radius: 2px;
border: 1px solid;
background: #EEE;
}
input[type='range']::-ms-track {
box-sizing: border-box;
width: 210px;
height: 5px;
border-radius: 2px;
padding: 0px;
background: #777;
color: #777;
}
input[type='range']::-webkit-slider-thumb {
box-sizing: border-box;
padding: 0px;
height: 20px;
width: 10px;
border-radius: 2px;
border: 1px solid;
margin-top: -8px;
background: #EEE;
}
input[type='range']::-ms-thumb {
box-sizing: border-box;
padding: 0px;
height: 20px;
width: 10px;
border-radius: 2px;
border: 1px solid;
background: #EEE;
}
input[type="range"]::-ms-fill-lower {
background: transparent;
}
input[type='range']:focus {
outline: none;
}
.field-wrapper rangeinput:after {
position: absolute;
color: #777;
content: '20 40 60 80';
padding: 40px;
word-spacing: 20px;
left: 0px;
top: 0px;
z-index: -1;
}
.field-wrapper rangeinput {
padding: 0px;
position: relative;
}
.field-wrapper rangeinput output{
display: block;
margin-top: 20px;
color: #777;
}
.field-wrapper rangeinput output:before{
content:"Selected Value: ";
font-weight: bold;
}
.field-wrapper rangeinput body {
font-family: Calibri, Arial;
}