Например, загруженная страница имеет размер 6000 пикселей, высота страницы 1 – 500 пикселей, а высота страницы 2 – 300 пикселей. Когда страница загружается, размер элемента содержимого устанавливается на 6000 пикселей. Тем не менее, когда я нажимаю на страницу 1, чтобы загрузить ее в элемент div содержимого, размер элемента содержимого остается равным 6000 пикселей, хотя сам контент имеет высоту всего 500 пикселей, то же самое касается страницы 2 и т. д.
Код: Выделить всё
$(document).ready(function() {
//Load content on page load
$("#content").html('[list][*]Loading Content...[/list]')
.load("/content/" + "projects.php", null, function() {
contentHeight = $("#content").height();
selectHeight = $("#select").height();
$("#spacer").height(contentHeight + "px")
.css({
"top": selectHeight + 40 + "px"
});
});
//Load content on click
$(".load").click(function() {
loadName = $(this).attr("id");
$("#content").html('[list][*]Loading Content...[/list]')
.load("/content/" + loadName + ".php", null, function() {
contentHeight = $("#content").height();
selectHeight = $("#select").height();
if (selectHeight < contentHeight) {
$("#spacer").css({
"top": selectHeight + 40 + "px",
"display": "block"
})
.height(contentHeight + "px");
} else {
$("#spacer").css({
"display": "none"
});
return;
}
});
});
});Код: Выделить всё
#select {
width: 215px;
top: 20px;
left: 10px;
position: absolute;
}
#spacer {
border-right: 2px solid #000000;
left: 10px;
width: 215px;
position: absolute;
}
#content {
left: 227px;
top: 20px;
width: 703px;
padding: 0;
margin: 0;
position: absolute;
}Код: Выделить всё
[list]
[*][url=javascript:void(0)]page1[/url]
[*][url=javascript:void(0)]page2[/url]
[/list]
Подробнее здесь: https://stackoverflow.com/questions/146 ... on-content
Мобильная версия