Why is my video bar not finishing to the end? - css

I have a video bar (#progressBar) that moves as the video is playing. The function works and updates correctly. But once the video is finished, the video bar isn't finished. This is what it looks like:
HTML
<div id="skin">
<video id="myMovie" width="640" height="360" autoplay>
<source src="videos/Queen - Killer Queen.mp4">
</video>
<nav>
<div id="buttons">
<i class="fa fa-pause" aria-hidden="true" id="playButton"></i>
</div>
<span id='current'>0:00 / </span> <span id='duration'> 0:00</span>
<div id="defaultBar">
<div id="progressBar"></div>
</div>
<div style="clear:both"></div>
</nav>
</div>
CSS
body {
text-align: center;
display: block;
}
nav {
margin: 5px 0px;
}
#myMovie {
width: 850px;
height: 480px;
}
#myMovie::-webkit-media-controls {
display: none;
}
#playButton {
position: relative;
top: -47px;
left: -294px;
padding: 10px;
padding-bottom: 13px;
padding-left: 20px;
padding-right: 20px;
color: white;
cursor: pointer;
}
#skin {
position: relative;
}
#defaultBar {
position: relative;
float: left;
top: -90px;
left: 481px;
width: 622px;
height: 3px;
background-color: #C2C2C2;
}
#progressBar {
position: absolute;
width: 0;
height: 3px;
background-color: #CA241E;
}
#current, #duration {
position: relative;
top: -77px;
left: -540px;
color: white;
font-family: Open Sans;
font-size: 13px;
}
#duration {
left: -540px;
}
JS
$(document).ready(function() {
$("#myMovie").on(
"timeupdate","play",
function(event) {
function format(s) {
m = Math.floor(s / 60);
m = (m >= 10) ? m : "0" + m;
s = Math.floor(s % 60);
s = (s >= 10) ? s : "0" + s;
return m + ":" + s;
}
var time = format(Math.floor(this.currentTime) + 1);
var duration = format(Math.floor(this.duration) + 1);
onTrackedVideoFrame(time,duration);
});
});
function onTrackedVideoFrame(currentTime, duration){
$("#current").text(currentTime + " / ");
$("#duration").text(duration);
}
$("#myMovie").on("ended",
function(event) {
alert("f");
});
function doFirst(){
barSize=575;
myMovie=document.getElementById('myMovie');
playButton=document.getElementById('buttons');
defaultBar=document.getElementById('defaultBar');
progressBar=document.getElementById('progressBar');
playButton.addEventListener('click', playOrPause, false);
defaultBar.onclick=clickedBar('click', clickedBar, false);
}
function playOrPause(){
if(!myMovie.paused && !myMovie.ended){
myMovie.pause();
playButton.innerHTML='<i class="fa fa-play" aria-hidden="true" id="playButton"></i>';
window.clearInterval(updateBar);
}else{
myMovie.play();
playButton.innerHTML='<i class="fa fa-pause" aria-hidden="true" id="playButton"></i>';
updateBar=setInterval(update, 500);
}
}
function update(){
var size=parseInt (myMovie.currentTime*barSize/myMovie.duration);
if(!myMovie.ended){
progressBar.style.width=size+'px';
}else{
progressBar.style.width=size+'px';
playButton.innerHTML='<i class="fa fa-play" aria-hidden="true" id="playButton"></i>';
window.clearInterval(updateBar);
}
}
function clickedBar(e){
if(!myMovie.paused && !myMovie.ended){
var mouseX=e.pageX-bar.offsetLeft;
var newTime=mouseX*myMovie.duration/barSize;
myMovie.currentTime=newTime;
progressBar.style.width=mouseX+'px';
}
}
window.addEventListener('load', doFirst, false);

I cant be sure as the code doesnt work for me at all when I'm copying it 1:1.
But it seems like you're initializing the variable barSize with the wrong value.
function doFirst(){
barSize=575;
...
"#defaultBar" seems to be the ProgressBar itself so the correct value to initialize barSize with should be 622:
function doFirst(){
barSize=622; // this should work
...

Related

How to edit the javascript codes that run when the wordpress button is clicked?

I added a modal on my Wordpress website and placed a code in the modal's pop-up window. When the button of this modal is clicked, I want the codes in the opened window to start working, but without clicking the button, the codes work immediately. There is a backcounter in the codes and the Download button that comes after it. And my modal button HTML anchor "downloadFileDoc"
<div dir="ltr" style="text-align: center;">
<div id="timer_animation" style="display: inline-block;">
<div class="timer-container">
<div class="loading-spinner" id="loading_spinner">
<div class="loading-spinner-counter" id="loading_spinner_counter"></div>
</div>
</div>
</div>
<br />
<div id="download_text" style="display: block;">Generating Download Link...</div>
<button id="download_button" style="display: none; margin: auto; ">DOWNLOAD NOW</button>
<noscript>JavaScript needs to be enabled in order to be able to download.</noscript>
<style>
.timer-container {
text-align: center;
position: relative;
}
.loading-spinner {
width: 30px;
height: 30px;
border-radius: 50%;
border: 2px solid #658864;
border-top-color: #333333;
animation: spin 1s linear infinite;
position: relative;
}
.loading-spinner-counter {
width: 100%;
height: 100%;
position: absolute;
top: 0;
left: 0;
text-align: center;
line-height: 30px;
font-size: 22px;
color: #333333;
}
#keyframes spin {
0% {
transform: rotate(360deg);
}
100% {
transform: rotate(360deg);
}
}
</style>
<script type="application/javascript">
(function()
{
var count = 5;
var timer_animation = document.getElementById("timer_animation");
var loading_spinner_counter = document.getElementById("loading_spinner_counter");
var download_text = document.getElementById("download_text");
var download_button = document.getElementById("download_button");
var download_link = document.getElementById("download_link");
download_button.onclick = function() {
window.location.href = download_link.href;
};
var timer = setInterval(function(){
// if countdown equals 0, the next condition will evaluate to false and the else-construct will be executed
if (count) {
// update timer value
loading_spinner_counter.innerHTML = count;
// decrease counter
count--;
} else {
// stop timer
clearInterval(timer);
// hide countdown
timer_animation.style.display = "none";
download_text.style.display = "none";
// show download button
download_button.style.display = "block";
}
}, 1000);
})();
</script>

In React, is there a way to have a toggle switch, onChange or onClick, switch to either the first function (thirtyDays) or the second function (year)?

I am trying to allow the user to select what will display via a toggle switch. For example, I have two functions: thirtyDays & year. Either onChange or onClick, I would like for the user to be able to switch which function is called. Is there a way to do this? Here is my code for the ToggleButton component:
thirtyDays = (props) => {
console.log("the past 30 days of transactions");
var now = new Date();
now.setDate(now.getDate() - 30);
}
year = (props) => {
console.log("year of transactions");
var now = new Date();
now.setDate(now.getDate() - 365);
}
render() {
return (
<label className="switch">
{
<>
{" "}
<input type="checkbox" id="togBtn" />
<div type="button" className="slider round">
<span className="on">Year</span>
<span className="off">30 Days</span>
</div>
</>
}
</label>
);
}
}
Here is my css:
.switch {
position: relative;
display: inline-block;
width: 175px;
height: 50px;
}
.switch input {display:none;}
.slider {
position: absolute;
cursor: pointer;
top: 0;
left: 0;
right: 0;
bottom: 0;
background-color: forestgreen;
-webkit-transition: .4s;
transition: .4s;
}
.slider:before {
position: absolute;
content: "";
height: 50px;
width:50px;
left: 10px;
background-color: white;
-webkit-transition: .4s;
transition: .4s;
}
input:checked + .slider {
background-color: #2ab934;
}
input:focus + .slider {
box-shadow: 0 0 1px rgb(2, 61, 2);
}
input:checked + .slider:before {
-webkit-transform: translateX(100px);
-ms-transform: translateX(100px);
transform: translateX(100px);
}
/*------ ADDED CSS ---------*/
.on
{
display: none;
}
.off, .on
{
color: white;
position: absolute;
transform: translate(-50%,-50%);
top: 50%;
left: 50%;
font-size: 10px;
font-family: Verdana, sans-serif;
font-size: 15px;
}
input:checked+ .slider .on
{display: block;}
input:checked + .slider .off
{display: none;}
/*--------- END --------*/
/* Rounded sliders */
.slider.round {
border-radius: 34px;
}
.slider.round:before {
border-radius: 50%;}
Here is my codesandbox: https://codesandbox.io/s/ancient-rgb-y62rm?file=/src/App.js
You can decide about function which you call checking state of your checkbox inside another function. Example:
const changePeriod = (e) => {
if ( console.log( e.target.checked ) ) {
year( /* your params */ )
} else {
thirtyDays( /* your params */ )
}
}
return (
<div className="App">
<input type="checkbox" onChange={ changePeriod }/>
</div>
);
You would have to maintain the toggle state in your component. Or, if you're willing to use a plugin, you could try react-switch.
Here's a working example - https://codesandbox.io/s/frosty-water-l4pr6

CSS Blobs Animation

Trying to make these gooey CSS moving blobs. The basic setup seems to be that you give the circles blur and then add contrast to their container. The issue is that whenever I do that with custom colors the entire element just disappears. I tried it on these demos and same thing. Does anyone know why or know a workaround?
Here is a tutorial I've been following:
https://css-tricks.com/shape-blobbing-css/
Here is the code:
$(document).ready(function() {
$(".dot").hover(function() {
var cur = $(this);
var dest = cur.position().left;
var t = 0.6;
TweenMax.to($(".select"), t, {
x: dest,
ease: Back.easeOut
})
});
var lastPos = $(".select").position().left;
function updateScale() {
var pos = $(".select").position().left;
var speed = Math.abs(pos - lastPos);
var d = 44;
var offset = -20;
var hd = d / 2;
var scale = (offset + pos) % d;
if (scale > hd) {
scale = hd - (scale - hd);
}
scale = 1 - ((scale / hd) * 0.35);
TweenMax.to($(".select"), 0.1, {
scaleY: scale,
scaleX: 1 + (speed * 0.06)
})
lastPos = pos;
requestAnimationFrame(updateScale);
}
requestAnimationFrame(updateScale);
$(".dot:eq(0)").trigger("mouseover");
})
.text {
position: relative;
left: 110px;
top: 10px;
font-family: 'Baskerville', Georgia, serif;
font-size: 17px;
}
a {
color: inherit;
}
.dots {
list-style-type: none;
background: white;
-webkit-filter: blur(5px) contrast(10);
padding: 0;
margin: 0;
padding-top: 20px;
padding-bottom: 20px;
padding-left: 20px;
margin-left: -10px;
padding-right: 10px;
position: relative;
left: 100px;
top: 30px;
}
.dot {
display: inline-block;
vertical-align: middle;
border-radius: 100%;
width: 30px;
height: 30px;
background: black;
margin-left: 5px;
margin-right: 5px;
cursor: pointer;
color: white;
position: relative;
z-index: 2;
}
.select {
display: block;
border-radius: 100%;
width: 40px;
height: 40px;
background: black;
//opacity:0.6;
//transition:transform 300ms ease-in-out;
position: absolute;
z-index: 3;
top: 15px;
left: 0px;
pointer-events: none;
}
<div class="text">
<h1>Gooey pagination</h1>
Based on a dribbble by Kreativa Studio. <br />
Made by Lucas Bebber. <br /> <br />
Hover on the dots bellow
</div>
<ul class="dots">
<li class="select"></li>
<li class="dot"></li>
<li class="dot"></li>
<li class="dot"></li>
<li class="dot"></li>
<li class="dot"></li>
</ul>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/gsap/1.13.1/TweenMax.min.js"></script>
If you go to one of their demos and try changing the color to something like pink or #A0D9A8 you'll see what I mean:
This is really interresting. It seems that to work the color must cause a very strong contrast because of the filter rule used. So you will have to use flashy colors to make them appear. The colors pink or #A0D9A8 aren't flashy enought for the blur that's going to make him disappear. So try to use more flashy colors like #e83ce8 that's like a pink color:
$(document).ready(function() {
$(".dot").hover(function() {
var cur = $(this);
var dest = cur.position().left;
var t = 0.6;
TweenMax.to($(".select"), t, {
x: dest,
ease: Back.easeOut
})
});
var lastPos = $(".select").position().left;
function updateScale() {
var pos = $(".select").position().left;
var speed = Math.abs(pos - lastPos);
var d = 44;
var offset = -20;
var hd = d / 2;
var scale = (offset + pos) % d;
if (scale > hd) {
scale = hd - (scale - hd);
}
scale = 1 - ((scale / hd) * 0.35);
TweenMax.to($(".select"), 0.1, {
scaleY: scale,
scaleX: 1 + (speed * 0.06)
})
lastPos = pos;
requestAnimationFrame(updateScale);
}
requestAnimationFrame(updateScale);
$(".dot:eq(0)").trigger("mouseover");
})
.text {
position: relative;
left: 110px;
top: 10px;
font-family: 'Baskerville', Georgia, serif;
font-size: 17px;
}
a {
color: inherit;
}
.dots {
list-style-type: none;
background: white;
-webkit-filter: blur(5px) contrast(10);
padding: 0;
margin: 0;
padding-top: 20px;
padding-bottom: 20px;
padding-left: 20px;
margin-left: -10px;
padding-right: 10px;
position: relative;
left: 100px;
top: 30px;
}
.dot {
display: inline-block;
vertical-align: middle;
border-radius: 100%;
width: 30px;
height: 30px;
background: #e83ce8;
margin-left: 5px;
margin-right: 5px;
cursor: pointer;
color: white;
position: relative;
z-index: 2;
}
.select {
display: block;
border-radius: 100%;
width: 40px;
height: 40px;
background: #e83ce8;
position: absolute;
z-index: 3;
top: 15px;
left: 0px;
pointer-events: none;
}
<div class="text">
<h1>Gooey pagination</h1>
Based on a dribbble by Kreativa Studio. <br />
Made by Lucas Bebber. <br /> <br />
Hover on the dots bellow
</div>
<ul class="dots">
<li class="select"></li>
<li class="dot"></li>
<li class="dot"></li>
<li class="dot"></li>
<li class="dot"></li>
<li class="dot"></li>
</ul>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/gsap/1.13.1/TweenMax.min.js"></script>
Check what it says on the entire page over on CSS tricks, about brightness especially.
You just need to change the following and you will see pink blorbs.
.dots{
...
-webkit-filter: blur(5px) contrast(10) brightness(-50);
...
}
.dot {
...
background: /* black */ pink;
...
}
.select { /* EDIT */
...
background: /* black */ pink;
...
}
EDIT: I used a CSS variable in this fiddle:
https://jsfiddle.net/p97qxzew/

Toggle visibility of multiple elements sharing the same class name

I have a slider and I want it when it slides one way it hides all the elements on the page with a classname="siteContainer". When I click it again I want it to display all the elements with the classname="siteContainer"
Because there are many elements I need a loop (which I have). I have managed to make all the elements visible but been unable to make the visible again.
The elements are not contiguous so cannot be grouped into one div with one ID.
It is in codepen https://codepen.io/payling/pen/MRmvwY
and below
<script>
function setDisplay(className, displayValue) {
var items = document.getElementsByClassName(className);
for (var i=0; i < items.length; i++) {
items[i].style.display = displayValue;
}
}
function showsiteContainer() {
setDisplay("siteContainer", "none");
}
</script>
function showsiteContainer() {
var x = document.getElementById("block");
if (x.style.display === "none") {
x.style.display = "block";
} else {
x.style.display = "none";
}
}
<style>
.siteContainer {
display:flex;
width:40px;
hieght:40px;
color:black;
text-decoration:none;
font-size:13px;
padding:5px;
border-top-color: rgb(133, 130, 130);
border-top-style:dotted;
border-width: 1px;
}
/* SLIDE BUTTON*/
.switch {
position: relative;
display: inline-block;
width: 40px;
height: 20px;
}
.switch input {
opacity: 0;
width: 0;
height: 0;
}
.slider {
position: absolute;
cursor: pointer;
top: 0;
left: 0;
right: 0;
bottom: 0;
background-color: #EDEDED;
-webkit-transition: .4s;
transition: .4s;
}
.slider:before {
position: absolute;
content: "";
height: 12px;
width: 12px;
left: 4px;
bottom: 4px;
background-color: white;
-webkit-transition: .4s;
transition: .4s;
}
input:checked + .slider {
background-color: #1C77C3;
}
input:focus + .slider {
box-shadow: 0 0 1px #2196F3;
}
input:checked + .slider:before {
-webkit-transform: translateX(18px);
-ms-transform: translateX(18px);
transform: translateX(18px);
}
/* Rounded sliders */
.slider.round {
border-radius: 24px;
}
.slider.round:before {
border-radius: 50%;
}
</style>
<body>
<div>
<span>DETAILS</span>
<label class="switch">
<input type="checkbox" onclick="showsiteContainer()" >
<span class="slider round"></span>
</label>
</div>
<div>
<div class="siteContainer">an element</div>
<div class="siteContainer">2nd element</div>
</div>
<div class="siteContainer">3rd element</div>
<div class="siteContainer">4th element</div>
</div>
</body>
Have a look at your example with a slight modification, I rewrote your function with :
function showsiteContainer() {
var elements = document.getElementsByClassName("siteContainer");
Array.prototype.forEach.call(elements, function(el) {
if (el.style.display === "none") {
el.style.display = "block";
} else {
el.style.display = "none";
}
});
}
https://codepen.io/Xolkys/pen/rbmzXz

Is there a CSS way to automatically set the width of an element based on the size of text strings?

I’m creating a styled select menu in which I’m styling an unordered list that is replacing my select element.
<div class="select">
<select name="distance" id="distance" class="select-hidden">
<option value="5.0 5"><font><font>5 mi</font></font></option>
<option value="6.0 4">6 km</option>
<option value="10.0 4" selected="selected"><font><font>10 km</font></font></option></select><div class="select-styled">10 km</div><ul class="select-options" style="display: none;"><li rel="5.0 5"><font><font>5 mi</font></font></li><li rel="6.0 4"><font><font>6 km</font></font></li><li rel="10.0 4"><font><font>10 km</font></font></li></ul>
</div>
I then have this style
.select {
cursor: pointer;
display: inline-block;
position: relative;
font-size: 16px;
color: #000000;
width: 220px;
height: 42px;
}
Right now I’m hard-coding the width (220px) and my question is can I build this in a less rigid way such that the width will automatically be the width of the longest element name? Here is the Fiddle that illustrates my dilemma — https://jsfiddle.net/n73ao02h/13/ .
How about that: https://jsfiddle.net/n73ao02h/14/
A select-box without any width will always style according to its options. So we use that...
First step is to remove the fixed width.
We get the width in JS before we add display:none to it.
We then generate a temporary element styled-select with zero width to automatically get the padding defined in CSS without hardcoding it.
We then have all we need to calculate the new width of your styled select-box:
/* ... */
var $paddingCalculator = $('<div />', {
'class' : "select-styled test"
}).css({
width : 0,
visibility : "hidden"
}).appendTo("body");
var paddingWidth = $paddingCalculator.outerWidth();
$paddingCalculator.remove();
var selectWidth = $this.width() + paddingWidth;
$this.addClass('select-hidden');
if ( !$this.parent().hasClass('select') ) {
var $wrapper = $("<div />", {
'class' : "select"
}).css({
width : selectWidth
});
$this.wrap( $wrapper );
} // if
/* ... */
 
little addendum:
Keep in mind that both - the original select box and your styled div - need to have the same font-size (and anything text-styling related, such as font-family, font-weight, letter-spacing, ...) so that the calculated dimensions will be correct.
Don't set the width and don't set display:none on the select, plus set white-space:nowrap on your div.select-styled :
$(function() {
$('select').each(function(){
styleSelectMenu($(this));
});
});
// This method applies the styles to our select menu
function styleSelectMenu(selectMenu)
{
var $this = $(selectMenu), numberOfOptions = $(selectMenu).children('option').length;
$this.addClass('select-hidden');
if ( !$this.parent().hasClass('select') ) {
$this.wrap('<div class="select"></div>');
} // if
if ( !$this.next().hasClass('select-styled') ) {
$this.after('<div class="select-styled"></div>');
} // if
var $styledSelect = $this.next('div.select-styled');
$styledSelect.text($this.children('option').eq(0).text());
if ( $styledSelect.parent().find('ul').length > 0 ) {
$styledSelect.parent().find('ul').remove();
} // if
var $list = $('<ul />', {
'class': 'select-options'
}).insertAfter($styledSelect);
for (var i = 0; i < numberOfOptions; i++) {
$('<li />', {
text: $this.children('option').eq(i).text(),
rel: $this.children('option').eq(i).val()
}).appendTo($list);
}
var $listItems = $list.children('li');
// This is the event when someone opens the list
$styledSelect.unbind('click')
$styledSelect.click(function(e) {
e.stopPropagation();
$('div.select-styled.active').each(function(){
$(this).removeClass('active').next('ul.select-options').hide();
});
$(this).toggleClass('active').next('ul.select-options').toggle();
});
// This is the event when someone actually selects something from the list
$listItems.unbind('click.selectStyledItem')
$listItems.bind('click.selectStyledItem', function(event) {
clickListItem($styledSelect, $this, $(this), $list);
});
$(document).click(function() {
$styledSelect.removeClass('active');
$list.hide();
});
var selectedIndex = $this[0].selectedIndex;
if (selectedIndex > 0) {
var name = $this.attr("name")
var selectedText = $( "select[name='" + name + "'] option:selected" ).text();
selectItemFromStyledList($styledSelect, $this, selectedText, $list);
} // if
}
// This is the method that will select an item from the styled list
function selectItemFromStyledList(styledSelect, selectMenu, selectedText, listToHide)
{
$(styledSelect).text(selectedText).removeClass('active');
$(selectMenu).val($(selectMenu).attr('rel'));
$(listToHide).hide();
// Select option in the underlying list so that the form gets submitted
// with the right values
selectedOption = $(selectMenu).find("option").filter(function () { return $(this).html() == selectedText; });
$(selectMenu).find("option[selected='selected']").removeAttr("selected");
$(selectedOption).attr("selected","selected");
} // selectItemFromStyledList
// Called when someone clicks an item from the styled list
// The event data should contain the following parameters:
// styledSelect - the <div> element that contains the styled menu
// selectMenu - the actual form element that contains the items
// listItemClicked - the item that was clicked.
// list - THe <UL> element containig the <li> options
function clickListItem(styledSelect, selectMenu, listItemClicked, list)
{
var $styledSelect = $(styledSelect);
var $selectMenu = $(selectMenu);
var $listItem = $(listItemClicked);
var $list = $(list);
event.stopPropagation();
var selectedText = $listItem.text();
selectItemFromStyledList($styledSelect, $selectMenu, selectedText, $list)
} // clickListItem
#statSearchFields {
vertical-align: top;
font-size: 90%;
}
.selectMenu {
font-family: 'Oxygen', sans-serif;
font-size: 20px;
height: 50px;
-webkit-appearance: menulist-button;
}
.select-hidden {
visibility: hidden;
padding-right: 10px;
}
.select {
cursor: pointer;
display: inline-block;
position: relative;
font-size: 16px;
color: black;
height: 42px;
}
.select-styled {
white-space: nowrap;
}
.select-styled {
position: absolute;
top: 0;
right: 0;
bottom: 0;
left: 0;
background-color: gray;
padding: 11px 12px;
#include transition(all 0.2s ease-in);
&:after {
content:"";
width: 0;
height: 0;
border: 7px solid transparent;
border-color: black transparent transparent transparent;
position: absolute;
top: 16px;
right: 10px;
}
&:hover {
background-color: darken(gray, 2);
}
&:active, &.active {
background-color: darken(gray, 5);
&:after {
top: 9px;
border-color: transparent transparent $select-color transparent;
}
}
}
.select-options {
display: none;
position: absolute;
top: 100%;
right: 0;
left: 0;
z-index: 999;
margin: 0;
padding: 0;
list-style: none;
background-color: darken(gray, 5);
overflow: scroll;
li {
margin: 0;
padding: 12px 0;
text-indent: 15px;
border-top: 1px solid darken(gray, 10);
#include transition(all 0.15s ease-in);
&:hover {
color: gray;
background: black;
}
&[rel="hide"] {
display: none;
}
}
}
#statSearchContainer {
padding: 10px;
font-family: "Calibre", "Helvetica Neue", "Helvetica", "Roboto", "Arial", sans-serif;
background-color: tan;
display: table;
}
#statSearchContainer h1 {
margin: 5px 0;
font-size: 1.0em;
}
#stat-search-form {
display: block;
padding: 0px;
}
#stat-search-form form input {
vertical-align: middle;
}
#statSearchFields {
vertical-align: top;
font-size: 90%;
}
.searchField {
display: inline-block;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div id="statSearchContainer">
<div class="searchField">
Distance<br/>
<select name="distance" id="distance"><option value="5.0 5">5 mi</option>
<option value="6.0 4">6 km</option>
<option selected="selected" value="10.0 4">10 km</option></select>
</div>
<input alt="Search" type="image" src="/assets/magnifying-glass-0220f37269f90a370c3bb60229240f2ef2a4e15b335cd42e64563ba65e4f22e4.png" class="search_button">
</div>
</div>

Resources