2014-11-11 2 views
1

На моем веб-сайте есть проект на школьный проект, созданный с помощью анимации Javascript.Перемещение пробелов и фона

Проблема: 1; Фон перемещается, когда открываются 2 или более faqs. 2; На заднем плане есть пустое пространство.

The faq on my website (click for the image)

Javascript

var main = function() { 
 
$('.article').click(function() { 
 
    $('.article').removeClass('current'); 
 
    $('.description').hide(); 
 
     
 
    $(this).addClass('current'); 
 
    $(this).children('.description').show(); 
 
}); 
 

 
$(document).keypress(function(event) { 
 
     if(event.which === 111) { 
 
    $('.current').children('.description').toggle(); 
 
    } 
 
    else if(event.which === 110) { 
 

 
    var currentArticle = $('.current'); 
 
    var nextArticle = currentArticle.next(); 
 

 
    currentArticle.removeClass('current'); 
 
    nextArticle.addClass('current'); 
 
} 
 

 
}); 
 

 
}; 
 

 
$(document).ready(main);
The Css 
 

 
Body { 
 
    background: url('http://s3.amazonaws.com/codecademy-content/courses/ltp2/img/uber/black-thread.png'); 
 
    } 
 
.articles_title { 
 
    color:white; 
 
    font-size: 250%; 
 
    position: fixed; 
 
    top: 30px; 
 
    right: 50%; 
 
} 
 
p { 
 
    margin: 0; 
 
} 
 

 
.row { 
 
    margin: 0; 
 
} 
 

 
.articles { 
 
    margin-top: 16px; 
 
    margin-bottom: 16px; 
 
} 
 

 
.article { 
 
    color: #222; 
 
    background: rgba(255,255,255,.9); 
 
    border-spacing: 2px; 
 
    border-color: gray; 
 
    font-family: arial,sans-serif; 
 
    border-bottom: 1px #e5e5e5 solid; 
 
} 
 

 
.current .item { 
 
    background: rgba(206,220,206,.9); 
 
} 
 

 
.item { 
 
    cursor: pointer; 
 
    padding-top: 7px; 
 
    padding-bottom: 7px; 
 
    
 
} 
 

 
.item .source { 
 
    margin-left: 16px; 
 
} 
 

 
.item .title { 
 
    font-weight: bold; 
 
} 
 

 
.item .pubdate { 
 
    margin-right: 16px; 
 
} 
 

 
.item .pubdate { 
 
    text-align: right; 
 
} 
 

 
.description { 
 
    display: none; 
 
    padding-top: 10px; 
 
    padding-bottom: 10px; 
 
} 
 

 
.description h1 { 
 
    margin-top: 0px; 
 
    font-size: 16px; 
 
} 
 
/* the index.php css */ 
 

 
body { 
 
    left: 0; 
 
    margin: 0; 
 
    overflow: hidden; 
 
    position: relative; 
 
} 
 

 
/* Initial menu */ 
 
.menu { 
 
    background: url('http://s3.amazonaws.com/codecademy-content/courses/ltp2/img/uber/black-thread.png') repeat left top; 
 
    left: -285px; /* start off behind the scenes */ 
 
    height: 100%; 
 
    position: fixed; 
 
    width: 285px; 
 
} 
 
/* Basic styling */ 
 

 
.jumbotron { 
 
    background-image: url('http://i.imgur.com/JvdPG8h.png?1'); 
 
    height: 100%; 
 
    -webkit-background-size: cover; 
 
    -moz-background-size: cover; 
 
     -o-background-size: cover; 
 
      background-size: cover; 
 
} 
 

 
.menu ul { 
 
    border-top: 1px solid #636366; 
 
    list-style: none; 
 
    margin: 0; 
 
    padding: 0; 
 
} 
 

 
.menu li { 
 
    border-bottom: 1px solid #636366; 
 
    font-family: 'Open Sans', sans-serif; 
 
    line-height: 45px; 
 
    padding-bottom: 3px; 
 
    padding-left: 20px; 
 
    padding-top: 3px; 
 
} 
 

 
.menu a { 
 
    color: #fff; 
 
    font-size: 15px; 
 
    text-decoration: none; 
 
    text-transform: uppercase; 
 
} 
 

 
.icon-close { 
 
    cursor: pointer; 
 
    padding-left: 10px; 
 
    padding-top: 10px; 
 
} 
 

 
.icon-menu { 
 
    color: #fff; 
 
    cursor: pointer; 
 
    font-family: 'Open Sans', sans-serif; 
 
    font-size: 16px; 
 
    padding-bottom: 25px; 
 
    padding-left: 25px; 
 
    padding-top: 25px; 
 
    text-decoration: none; 
 
    text-transform: uppercase; 
 
} 
 

 
.icon-menu i { 
 
    margin-right: 5px; 
 
}
The index.php in the faq.php 
 

 
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> 
 
<!doctype html> 
 
<html> 
 
    <head> 
 
    <link href="http://s3.amazonaws.com/codecademy-content/courses/ltp2/css/bootstrap.min.css" rel="stylesheet"> 
 
    <link rel="stylesheet" href="styles/faq.css"> 
 
    </head> 
 
    <body> 
 
    <div class="articles container"> 
 
     
 
     <div class="article current"> 
 
     <div class="item row"> 
 
      <div class="col-xs-3"> 
 
      <p class="source">FLIGHT</p> 
 
      </div> 
 
      <div class="col-xs-6"> 
 
      <p class="title">Embraer adds third Legacy 500 prototype to flight test campaign</p> 
 
      </div> 
 
      <div class="col-xs-3"> 
 
      <p class="pubdate">Mar 23</p> 
 
      </div> 
 
     </div> 
 
     <div class="description row"> 
 
      <div class="col-xs-3">&nbsp;</div> 
 
      <div class="col-xs-6"> 
 
      <h1>Embraer adds third Legacy 500 prototype to flight test campaign</h1> 
 
      <p>The third Legacy 500 has joined Embraer's flight test programme aimed at delivering the midsize business jet in 2014. The airtcraft, serial number 003...</p> 
 
      </div> 
 
      <div class="col-xs-3">&nbsp;</div> 
 
     </div> 
 
     </div> 
 

 
     <div class="article"> 
 
     <div class="item row"> 
 
      <div class="col-xs-3"> 
 
      <p class="source">AW Commercial Aviation</p> 
 
      </div> 
 
      <div class="col-xs-6"> 
 
      <p class="title">CSeries Supplier Scramble</p> 
 
      </div> 
 
      <div class="col-xs-3"> 
 
      <p class="pubdate">Mar 22</p> 
 
      </div> 
 
     </div> 
 
     <div class="description row"> 
 
      <div class="col-xs-3">&nbsp;</div> 
 
      <div class="col-xs-6"> 
 
      <h1>CSeries Supplier Scramble</h1> 
 
      <p>Three months before the planned first flight of its CSeries, Bombardier is grappling with supplier issues crucial to meeting its production cost...</p> 
 
      </div> 
 
      <div class="col-xs-3">&nbsp;</div> 
 
     </div> 
 
     </div> 
 

 
     <div class="article"> 
 
     <div class="item row"> 
 
      <div class="col-xs-3"> 
 
      <p class="source">AW Commercial Aviation</p> 
 
      </div> 
 
      <div class="col-xs-6"> 
 
      <p class="title">CSeries Supplier Scramble</p> 
 
      </div> 
 
      <div class="col-xs-3"> 
 
      <p class="pubdate">Mar 22</p> 
 
      </div> 
 
     </div> 
 
     <div class="description row"> 
 
      <div class="col-xs-3">&nbsp;</div> 
 
      <div class="col-xs-6"> 
 
      <h1>CSeries Supplier Scramble</h1> 
 
      <p>Three months before the planned first flight of its CSeries, Bombardier is grappling with supplier issues crucial to meeting its production 
 
       </div> 
 
       <div class="col-xs-3">&nbsp;</div> 
 
     </div> 
 
     </div> 
 

 
     <div class="article"> 
 
     <div class="item row"> 
 
      <div class="col-xs-3"> 
 
      <p class="source">AW Commercial Aviation</p> 
 
      </div> 
 
      <div class="col-xs-6"> 
 
      <p class="title">CSeries Supplier Scramble</p> 
 
      </div> 
 
      <div class="col-xs-3"> 
 
      <p class="pubdate">Mar 22</p> 
 
      </div> 
 
     </div> 
 
     <div class="description row"> 
 
      <div class="col-xs-3">&nbsp;</div> 
 
      <div class="col-xs-6"> 
 
      <h1>CSeries Supplier Scramble</h1> 
 
      <p>Three months before the planned first flight of its CSeries, Bombardier is grappling with supplier issues crucial to meeting its production 
 
       </div> 
 

 
     
 
    </div> 
 
    <script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script> 
 
    <script src="js/faq.js"></script> 
 
    </body> 
 
</html>

ответ

0

Я jsfiddle ваш вопрос http://jsfiddle.net/wz7eojqp/

Я не мог найти проблемы, которые вы описали.

, но я думаю, что в отношении пробела в нижней части вашей страницы проблема заключается в пометке браузера по умолчанию. попробуйте body{margin: 0;} или даже лучше сбросить код.

http://meyerweb.com/eric/tools/css/reset/

+0

Большое спасибо за помощь и время! Проблема становится понятной с использованием полного веб-сайта, но ваш ответ исправил все, и мне нравится идея только открытия одной статьи за раз. – NightShift

0

Пожалуйста, закройте все (!) ваши HTML-теги. Это устранит многие проблемы.

Я создал jsfiddle: http://jsfiddle.net/7ypk522y/ Я удалил свой CSS класс .jumbotron потому, что вы не используете его и изменили его следующие строки. Надеюсь, это решит вашу проблему.

body { 
    background: url("http://i.imgur.com/JvdPG8h.png") no-repeat center center fixed; 
    -webkit-background-size: cover; 
    -moz-background-size: cover; 
    -o-background-size: cover; 
    background-size: cover; 
    background-repeat: no-repeat; 
    padding: 20px; 
} 
+0

Хорошо, спасибо за вашу помощь. Я буду использовать оба ответа, чтобы сделать все возможное. Теперь я, наконец, понимаю это. (класс .jumbotron был для анимации меню javascript, которую я спрятал, потому что я не был уверен, следует ли нам его использовать). – NightShift

Смежные вопросы