html JS Bin //来源http://jsbin.com/lituhib

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了html JS Bin //来源http://jsbin.com/lituhib相关的知识,希望对你有一定的参考价值。

$( document ).ready(function() {
    
	var lightBox = $('#lightbox'),
		lightBoxContent = $('#lb-content');
	
	var positionLightbox = function() {
		var veiwWidth = $(window).width();
		var	lbContentMargin = (veiwWidth / 2) - 200;
		var	lbContent = $('#lb-content');
	
		lbContent.css({
			'left' : lbContentMargin + 'px',
			'top' : ($(window).height() / 2) - 200 + 'px'
		});
	};
	
	$('#search-submit').click(function() {
		lightBox.fadeIn(function() {
			lightBoxContent.show();                               
		});
		positionLightbox();
	});
	
	$('#lb-close').click(function() {
		lightBox.hide();
		lightBoxContent.hide();
	});
	
});
body {color: #fff; font-family: arial; font-family: arial;}
#lightbox {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    text-align: center;
    display: none;  
	background-color: #000;
    opacity: 0.1;
	z-index: 99;
}  
#lb-content {
    color: #222;
    height: 250px;
    width: 500px;
    border: 8px solid #F7B900;
    background-color: #fff;
    position: fixed;
	top:0px;
	left:0px;
    text-align: center;
    padding-top: 10px;
    border-radius: 4px;
    display: none;
	z-index: 100;
}
#lb-close {
  display: block;
  height: 25px;
  width: 25px;
  background-color: red;
  color: #fff;
  position: absolute;
  top: -25px;
  right: -25px;
  cursor: pointer;
  text-align: center;
  border-radius: 100px;
  line-height: 23px;
  font-size: 20px;
  font-weight: bold;   
}
<!DOCTYPE html>
<html>
<head>
<script src="https://code.jquery.com/jquery-1.9.1.min.js"></script>
  <meta charset="utf-8">
  <title>JS Bin</title>
</head>
<body>
  <button id="search-submit">open lb</button>
  <div id="lightbox"></div>
  <div id="lb-content">
       <span id="lb-close">x</span>
      <p>Wow!! Look at that. So simple.</p>        
  </div>
</body>
</html>

以上是关于html JS Bin //来源http://jsbin.com/lituhib的主要内容,如果未能解决你的问题,请参考以下文章

html 表单效果//来源http://js.jirengu.com/qacoxoleji

html Modal样式//来源http://js.jirengu.com/dituyefika

html alert效果//来源http://js.jirengu.com/tulahabene

html JS Bin //来源http://jsbin.com/muqigog

html JS Bin //来源http://jsbin.com/muqigog

html JS Bin //来源http://jsbin.com/muqigog