好的,这是我的小提琴
HTML(标准容器等)
<div id="container">
<div id="buttons-container"></div>
<div id="record">
<div id="record-content"></div>
<a href="#" id="bt-close" onclick="closeRecord(); return false;">Close</a></div>
</div>
CSS
a.bt-record {
display:block;
width:100px;
height:100px;
background:#999999;
color:#000;
line-height:100px;
text-align:center;
float:left;
margin:0 10px 10px 0;
text-decoration:none;
}
a { color:#fff; }
#container {
width:100%;
height:100%;
overflow:hidden;
position:relative;
}
#record {
position:absolute;
right:-240px;
top:100px;
width:200px;
height:200px;
background:#000;
padding:20px;
color:#fff;
z-index:1;
}
Javascript
//your data in a array of objects (could be something else)
var data = {
1 : {name:'Record 1', text:'This is the text 1', options:'Anything 1'},
2 : {name:'Record 2', text:'This is the text 2', options:'Anything 2'},
3 : {name:'Record 3', text:'This is the text 3', options:'Anything 3'},
4 : {name:'Record 4', text:'This is the text 4', options:'Anything 4'},
5 : {name:'Record 5', text:'This is the text 5', options:'Anything 5'},
6 : {name:'Record 6', text:'This is the text 6', options:'Anything 6'},
7 : {name:'Record 7', text:'This is the text 7', options:'Anything 7'},
8 : {name:'Record 8', text:'This is the text 8', options:'Anything 8'},
9 : {name:'Record 9', text:'This is the text 9', options:'Anything 9'}
};
$(document).ready(function() {
populateEntries();
});
//dynamically populate the entries
function populateEntries() {
for (entry in data){
console.log(entry);
$('#buttons-container').append('<a class="bt-record" href="#" onclick="showRecord(' + entry + '); return false;">' + data[entry].name + '</a>');
}
}
//show the record
function showRecord(id) {
//create the html
var html = '';
html += '<p>Name : ' + data[id].name + '</p>';
html += '<p>Text : ' + data[id].text + '</p>';
html += '<p>Name : ' + data[id].options + '</p>';
$('#record-content').html(html);
$('#record').animate({right:0}, 500);
}
function closeRecord() {
$('#record').animate({right:-240}, 500);
}
在此示例中,我动态填充记录,但如果您想要一种对 SEO 友好的方式,您可以直接在页面中创建 HTML。如果您有任何问题,请告诉我。