-------------------------------------------------------------------------
<html> | |
<head> | |
<meta charset="UTF-8"> | |
<title>JavaScript Browser Detect</title> | |
<meta name="viewport" content="width=device-width, initial-scale=1"> | |
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script> | |
</head> | |
<style> | |
html, body,div,dl,dt,dd,ul,ol,li,h1,h2,h3,h4,h5,h6,pre,form,fieldset,input,textarea,p,blockquote,th,td { | |
margin:0; | |
padding:0; | |
} | |
body{ | |
color: #333; | |
background:#f9f9f9; | |
font-family: 'Oswald', sans-serif; | |
font-size: 14px; | |
} | |
a{ | |
color: #fff; | |
text-decoration: none; | |
} | |
.clear-both { | |
clear: both; | |
} | |
.wrapper { | |
position: absolute; | |
left: 50vw; | |
top: 50vh; | |
transform: translateX(-50%) translateY(-50%); | |
width: 100%; | |
text-align: center; | |
} | |
.wrapper .browser { | |
display: inline-block; | |
height: 50px; | |
width: 50px; | |
filter: grayscale(100%); | |
position: relative; | |
background-repeat: no-repeat; | |
background-size: 50px 50px; | |
border-radius:100% | |
} | |
.wrapper .firefox { | |
background-image: url('https://pngimg.com/uploads/firefox/firefox_PNG21.png'); | |
} | |
.wrapper .chrome { | |
background-image: url('https://www.stickpng.com/assets/images/588525cd6f293bbfae451a37.png'); | |
} | |
.wrapper .safari { | |
background-image: url('https://cdn.imgbin.com/10/25/22/imgbin-safari-macbook-apple-web-browser-safari-wBjSKJ18wR30t1YgCRahBgdgN.jpg'); | |
} | |
.wrapper .edge { | |
background-image: url('https://icon-library.net/images/ie-icon-png/ie-icon-png-29.jpg'); | |
} | |
.wrapper .opera { | |
background-image: url('https://www.pinclipart.com/picdir/middle/71-716489_opera-logo-vector-png-opera-browser-logo-png.png'); | |
} | |
.wrapper .browser.active { | |
filter: grayscale(0%); | |
animation-duration: 1s; | |
animation-name: highlight; | |
animation-timing-function: ease-out; | |
animation-iteration-count: infinite; | |
animation-direction: alternate; | |
} | |
@keyframes highlight { | |
from { | |
top: 0; | |
} | |
to { | |
top: -20px; | |
} | |
} | |
</style> | |
<body> | |
<div class="wrapper"> | |
<div class="browser firefox"></div> | |
<div class="browser chrome"></div> | |
<div class="browser safari"></div> | |
<div class="browser edge"></div> | |
<div class="browser opera"></div> | |
</div> | |
<script> | |
$(document).ready(function() { | |
var browser; | |
var agent = navigator.userAgent.match(/(opera|chrome|safari|firefox|msie)\/?\s*(\.?\d+(\.\d+)*)/i); | |
if (navigator.userAgent.match(/Edge/i) || navigator.userAgent.match(/Trident.*rv[ :]*11\./i)) { | |
browser = "edge"; | |
} | |
else { | |
browser = agent[1].toLowerCase(); | |
} | |
$('.browser.' + browser).addClass("active"); | |
}); | |
</script> | |
</body> | |
</html> |
No comments:
Post a Comment