Ответ Алконьи более изящен, чем этот, и это действительно означает скорее демонстрацию, но вы можете увидеть здесь, что происходит.Наложение - это сетка с восемью блоками, а средний блок является областью формы, которая является открытой.
Убедитесь, что проверьте элементы с помощью консоли Firebug или Chrome, чтобы увидеть, как отображаются элементы, и стили CSSприменяется.
<div id="wrapper">
<div id="test">
<div>
Text: <input type="text"/> <input type="button" value="Undo"/>
</div>
<div>
Text: <input type="text"/> <input type="button"value="Undo"/>
</div>
<div>
Text: <input type="text"/> <input type="button"value="Undo"/>
</div>
</div>
</div>
html, body {
height: 100%;
margin: 0;
padding: 0;
}
#wrapper {
min-height: 100%;
padding: 0;
margin: 0;
overflow: auto;
}
#test {
background: #ddd;
margin: 0 auto;
padding: 0;
width: 330px;
}
#test div {
background: #ffa;
margin: 20px;
padding: 20px;
}
.overlay {
background: #dda;
opacity: .6;
position: absolute;
z-index: 1000;
}
function setOverlay(top, left, width, height) {
var screenwidth = parseInt($('body').width());
var screenheight = parseInt($('body').height());
var topleft = [0, 0, left, top];
$('<div class="overlay" style="top: '+topleft[0]+'px; '+
'left: '+topleft[1]+'px; '+
'width: '+topleft[2]+'px; '+
'height: '+topleft[3]+'px;"></div>').appendTo('body');
var topmiddle = [0, left, width, top];
$('<div class="overlay" style="top: '+topmiddle[0]+'px; '+
'left: '+topmiddle[1]+'px; '+
'width: '+topmiddle[2]+'px; '+
'height: '+topmiddle[3]+'px;"></div>').appendTo('body');
var topright = [0, left+width, screenwidth-left-width, top];
$('<div class="overlay" style="top: '+topright[0]+'px; '+
'left: '+topright[1]+'px; '+
'width: '+topright[2]+'px; '+
'height: '+topright[3]+'px;"></div>').appendTo('body');
var centerleft = [top, 0, left, height];
$('<div class="overlay" style="top: '+centerleft[0]+'px; '+
'left: '+centerleft[1]+'px; '+
'width: '+centerleft[2]+'px; '+
'height: '+centerleft[3]+'px;"></div>').appendTo('body');
var centerright = [top, left+width, screenwidth-left-width, height];
$('<div class="overlay" style="top: '+centerright[0]+'px; '+
'left: '+centerright[1]+'px; '+
'width: '+centerright[2]+'px; '+
'height: '+centerright[3]+'px;"></div>').appendTo('body');
var bottomleft = [top+height, 0, left, screenheight-top-height];
$('<div class="overlay" style="top: '+bottomleft[0]+'px; '+
'left: '+bottomleft[1]+'px; '+
'width: '+bottomleft[2]+'px; '+
'height: '+bottomleft[3]+'px;"></div>').appendTo('body');
var bottommiddle = [top+height, left, width, screenheight-top-height];
$('<div class="overlay" style="top: '+bottommiddle[0]+'px; '+
'left: '+bottommiddle[1]+'px; '+
'width: '+bottommiddle[2]+'px; '+
'height: '+bottommiddle[3]+'px;"></div>').appendTo('body');
var bottomright = [top+height, left+width, screenwidth-left-width, screenheight-top-height];
$('<div class="overlay" style="top: '+bottomright[0]+'px; '+
'left: '+bottomright[1]+'px; '+
'width: '+bottomright[2]+'px; '+
'height: '+bottomright[3]+'px;"></div>').appendTo('body');
}
$(document).ready(function(){
$('input[type="text"]').focus(function(){
$this = $(this).parent();
$('input[value="Undo"]').click();
setOverlay(
parseInt($this.offset().top),
parseInt($this.offset().left),
parseInt($this.outerWidth()),
parseInt($this.outerHeight())
);
});
$('input[value="Undo"]').click(function(){
$('.overlay').remove();
});
});
http://jsfiddle.net/userdude/3nRLJ/