Текст перекрывается из-за высоты в процентах

В настоящее время я работаю над веб-страницей. Я хотел добавить к заголовку фон, размер которого зависел бы от размера окна браузера. Это означало, что мне нужно было добавить высоту в div, чтобы я мог изменять высоту фона в процентах. Когда я добавил высоту в div, текст веб-страницы перекрылся. До добавления высоты текст был в полном порядке. Я надеюсь это имеет смысл. Будем признательны за любую помощь в том, почему текст перекрывается или как это исправить.

Вот HTML

<div>
      <p>
    <h1>Jonathan's Programming Notes!</h1>
  </p>
  <div>
    <p>
      <h2>Lesson 1</h2>
    </p>
  <div>
    <p>
      <h3>Blah</h3>
    </p>
    <p>
      Blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah.
    </p>
  </div>
  <div>
    <p>
      <h3>Content</h3>
    </p>
    <p>
      Content content content content content content content content content content content content content content content content content content content content content content content content content content content content content content content content content content content content content content content content content.
    </p>
  </div>
  <div>
    <p>
      <h3>Stuff</h3>
    </p>
    <p>
      Stuff stuff stuff stuff stuff stuff stuff stuff stuff stuff stuff stuff stuff stuff stuff stuff stuff stuff stuff stuff stuff stuff stuff stuff stuff stuff stuff stuff stuff stuff stuff stuff stuff stuff stuff stuff stuff stuff stuff stuff stuff stuff stuff stuff stuff stuff stuff stuff stuff stuff stuff stuff.
    </p>
  </div>
</div>
<div>
  <p>
    <h2>Lesson 2</h2>
  </p>
  <div>
    <p>
      <h3>Words</h3>
    </p>
    <p>
      Words words words words words words words words words words words words words words words words words words words words words words words words words words words words words words words words words words words words words words words words words words words words words words words words words words words words words words words words words words words words words.
    </p>
  </div>
  <div>
    <p>
      <h3>Text</h3>
    </p>
    <p>
      Text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text.
    </p>
  </div>
</div>
<div>
  <p>
    <h2>Lesson 3</h2>
  </p>
  <div>
    <p>
      <h3>Repetition</h3>
    </p>
    <p>
      Repetition Repetition Repetition Repetition Repetition Repetition Repetition Repetition Repetition Repetition Repetition Repetition Repetition Repetition Repetition Repetition Repetition Repetition Repetition Repetition Repetition Repetition Repetition Repetition Repetition Repetition Repetition Repetition Repetition Repetition Repetition Repetition Repetition Repetition Repetition Repetition Repetition Repetition.
    </p>
  </div>
  <div>
    <p>
      <h3>QWERTY</h3>
    </p>
    <p>
      QWERTY QWERTY QWERTY QWERTY QWERTY QWERTY QWERTY QWERTY QWERTY QWERTY QWERTY QWERTY QWERTY QWERTY QWERTY QWERTY QWERTY QWERTY QWERTY QWERTY QWERTY QWERTY QWERTY QWERTY QWERTY QWERTY QWERTY QWERTY QWERTY QWERTY QWERTY QWERTY QWERTY QWERTY QWERTY.
    </p>
  </div>

Вот CSS

div {
height:100vh;}
h1 {
background-image: url("http://gdurl.com/RGD0");
background-repeat: no-repeat;
background-size: 100% 104%;
max-width: 85%;
height: 70%;
font-size: 42px;
font-weight: 700;
text-align: center;
margin-left: auto;

Вот JSFiddle.


person Noobie123    schedule 29.07.2015    source источник
comment
не уверен, что понял вопрос - это то, что вы ищете? jsfiddle.net/9yq2wbax/6   -  person Rachel Gallen    schedule 29.07.2015
comment
это может быть jsfiddle.net/9yq2wbax/8?   -  person Rachel Gallen    schedule 29.07.2015


Ответы (1)


проблема заключалась в том, что все ваши div были установлены на 100vh. Я добавил заголовок div и оболочку для других ваших div и класс для него в вашем css. надеюсь, это имеет смысл

body {
  height: 100vh;
  background-image: url("http://gdurl.com/RGD0");
  background-repeat: no-repeat;
  background-size: 85% 70%;
  background-position: center top;
}
h1 {
  max-width: 85%;
  height: 70%;
  font-size: 42px;
  font-weight: 700;
  text-align: center;
  margin-left: auto;
  margin-right: auto;
  background-color: blue;
}
<body>
  <header>

    <h1>Jonathan's Programming Notes!</h1>
  </header>
  <div id="wrapper">
    <div>
      <p>
        <h2>Lesson 1</h2>
      </p>
      <div>
        <p>
          <h3>Blah</h3>
        </p>
        <p>
          Blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah
          blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah
          blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah.
        </p>
      </div>

      <div>
        <p>
          <h3>Content</h3>
        </p>
        <p>
          Content content content content content content content content content content content content content content content content content content content content content content content content content content content content content content content content
          content content content content content content content content content.
        </p>
      </div>
      <div>
        <p>
          <h3>Stuff</h3>
        </p>
        <p>
          Stuff stuff stuff stuff stuff stuff stuff stuff stuff stuff stuff stuff stuff stuff stuff stuff stuff stuff stuff stuff stuff stuff stuff stuff stuff stuff stuff stuff stuff stuff stuff stuff stuff stuff stuff stuff stuff stuff stuff stuff stuff stuff
          stuff stuff stuff stuff stuff stuff stuff stuff stuff stuff.
        </p>
      </div>
    </div>
    <div>
      <p>
        <h2>Lesson 2</h2>
      </p>
      <div>
        <p>
          <h3>Words</h3>
        </p>
        <p>
          Words words words words words words words words words words words words words words words words words words words words words words words words words words words words words words words words words words words words words words words words words words
          words words words words words words words words words words words words words words words words words words words.
        </p>
      </div>
      <div>
        <p>
          <h3>Text</h3>
        </p>
        <p>
          Text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text.
        </p>
      </div>
    </div>
    <div>
      <p>
        <h2>Lesson 3</h2>
      </p>
      <div>
        <p>
          <h3>Repetition</h3>
        </p>
        <p>
          Repetition Repetition Repetition Repetition Repetition Repetition Repetition Repetition Repetition Repetition Repetition Repetition Repetition Repetition Repetition Repetition Repetition Repetition Repetition Repetition Repetition Repetition Repetition
          Repetition Repetition Repetition Repetition Repetition Repetition Repetition Repetition Repetition Repetition Repetition Repetition Repetition Repetition Repetition.
        </p>
      </div>
      <div>
        <p>
          <h3>QWERTY</h3>
        </p>
        <p>
          QWERTY QWERTY QWERTY QWERTY QWERTY QWERTY QWERTY QWERTY QWERTY QWERTY QWERTY QWERTY QWERTY QWERTY QWERTY QWERTY QWERTY QWERTY QWERTY QWERTY QWERTY QWERTY QWERTY QWERTY QWERTY QWERTY QWERTY QWERTY QWERTY QWERTY QWERTY QWERTY QWERTY QWERTY QWERTY.
        </p>
      </div>
    </div>
</body>

person Rachel Gallen    schedule 29.07.2015
comment
jsfiddle.net/9yq2wbax/8 - person Rachel Gallen; 29.07.2015
comment
Спасибо! Ваш ответ удовлетворил мой вопрос. - person Noobie123; 29.07.2015
comment
@ Noobie123 очень рад это слышать! Добро пожаловать в Stack Overflow! - person Rachel Gallen; 29.07.2015