<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="initial-scale=1,maximum-scale=1,user-scalable=no,width=device-width">
<title>Document</title>
<style type="text/css">
.tips {
position: fixed;
top: 42%;
100%;
left: 50%;
text-align: center;
z-index: 999;
-webkit-transform: translateX(-50%);
transform: translateX(-50%);
}
.tips>div {
display: inline-block;
margin: 0;
padding: 0.2rem 0.3rem;
text-align: center;
color: #fff;
font-size: 0.6rem;
text-shadow: 1px 1px 1px #000;
border-radius: 50px;
/*line-height: 1.5rem;*/
background: rgba(0,0,0,.8);
}
h1{
font-size: 2rem;
}
</style>
</head>
<body>
<button>点击</button>
<div class="tips" style="display:none">
<div>fc</div>
</div>
<h1>1</h1>
<h2>2</h2>
<h3>3</h3>
<script type="text/javascript" src="../../js/jquery.min.js"></script>
<script type="text/javascript">
function showTips(text) {
$('.tips>div').text(text).parent().fadeIn().fadeOut(2000);
}
$("button").click(function(event) {
showTips();
});
</script>
<!-- //rem适配 -->
<script type="text/javascript">
(function(doc, win) {
var docEl = doc.documentElement,
resizeEvt = 'orientationchange' in window ? 'orientationchange' : 'resize',
recalc = function() {
var clientWidth = docEl.clientWidth;
if (!clientWidth) return;
docEl.style.fontSize = 20 * (clientWidth / 320) + 'px';
};
if (!doc.addEventListener) return;
win.addEventListener(resizeEvt, recalc, false);
doc.addEventListener('DOMContentLoaded', recalc, false);
})(document, window);
</script>
</body>
</html>