나는 메인 콘텐츠 #contentWrapper
과 높이를 같게 만들고 싶은 사이드 바 #menuOption
을 가지고 있습니다.자바 스크립트가 요소의 높이를 완전히 고려하지 않음
내 페이지의 기본 구조는 다음과 같습니다.
HTML
<div id="wrapper">
<div id="menuOption">
</div>
<div id="mainContent">
<div id="contentWrapper">
<div id="content">
<div id="lartDisqus">
<?php comments_template(); ?>
</div>
</div>
</div>
</div>
</div>
CSS
div#wrapper{height:100%;}
div#menuOption{float:left; width:40px; background:#444; min-height:100%;}
div#mainContent{min-height:100%; margin-left:40px; z-index:0; position:relative;}
div#contentWrapper{float:left; height:100%; width:85%; background-color:green;}
div#content{border-left:1px solid #ddd; border-top:1px solid #ddd; overflow:hidden;
margin-top:195px;}
jQuery를
jQuery(window).on("load",function(){
var documentHeight = jQuery('#contentWrapper').height();
jQuery('#menuOption').css('height',documentHeight + 'px');
});
jQuery(function($){
$(window).resize(function(){
var documentHeight = $('#contentWrapper').height();
$('#menuOption').css('height',documentHeight + 'px');
}).resize();
});
오전 데 문제가 있음 #mainOption
! = #contentWrapper
, PHP 함수 <?php comments_template(); ?>
을 제거하면 모든 것이 작동하고 자바 스크립트가 높이를 정확하게 계산합니다.
마지막으로 자바 스크립트를로드 중이며 확실히로드 중입니다.
JavaScript가 의 높이가 <?php comments_template(); ?>
으로 출력되는 것을 고려하지 않은 것처럼 보입니다.
라이브 사이트에 대한 링크를 추가했고 색깔이 #contentWrapper
이므로 조금 더 분명하게 볼 수 있습니다. http://lartmagazine.co.uk/lorem-ipsum-dolor-sit-amet/
질문에서 하나 이상의 언어를 삭제하십시오. 예를 들어 브라우저에서 코드를 보는 것만으로 이것이 PHP와 관련이 있는지를 판단 할 수 있습니까? –
좋아요, 저는 단지 자바 스크립트가로드되고 있음을 분명히하고 싶었습니다. – UzumakiDev
@OliCharlesworth 나는 그가 PHP 스크립트에서 js를로드하고 있다고 생각합니다 ... wordpress : O –