Содержание переходит заголовок - PullRequest
0 голосов
/ 22 апреля 2020

Мой заголовок исправлен, а текст установлен относительно. Когда я прокручиваю, текст идет поверх заголовка.

Я бы хотел, чтобы мой текст не go поверх заголовка.

Javascript находится в начале.

CSS находится в середине.

HTML в конце. Это моя фотография, надеюсь, она не содержит гиперссылок:)

Я новичок в веб-дизайне и прохожу курс по CS50. Кроме того, я уже пытался сделать текст фиксированным и относительный заголовок.

```function openNav() {
  document.getElementById("mobile__menu").style.width = "100%";
}

function closeNav() {
  document.getElementById("mobile__menu").style.width = "0";
}```
   ``` * {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 30px 10%;
  background-color: #24252a;
  position: fixed;
  width: 100%;
}

.logo {
  cursor: pointer;
}

.nav__links a,
.cta,
.overlay__content a {
  font-family: "Montserrat", sans-serif;
  font-weight: 500;
  color: #edf0f1;
  text-decoration: none;
}

.nav__links {
  list-style: none;
  display: flex;
}

.nav__links li {
  padding: 0px 20px;
}

.nav__links li a {
  transition: all 0.3s ease 0s;
}

.nav__links li a:hover {
  color: #0088a9;
}

.cta {
  padding: 9px 25px;
  background-color: rgba(0, 136, 169, 1);
  border: none;
  border-radius: 50px;
  cursor: pointer;
  transition: all 0.3s ease 0s;
}

.cta:hover {
  background-color: rgba(0, 136, 169, 0.8);
}```


/* Mobile Nav */

```.menu {
  display: none;
}

.overlay {
  height: 100%;
  width: 0;
  position: fixed;
  z-index: 1;
  left: 0;
  top: 0;
  background-color: #24252a;
  overflow-x: hidden;
  transition: all 0.5s ease 0s;
}

.overlay__content {
  display: flex;
  height: 100%;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.overlay a {
  padding: 15px;
  font-size: 36px;
  display: block;
  transition: all 0.3s ease 0s;
}

.overlay a:hover,
.overlay a:focus {
  color: #0088a9;
}

.overlay .close {
  position: absolute;
  top: 20px;
  right: 45px;
  font-size: 60px;
  color: #edf0f1;
}

@media screen and (max-height: 450px) {
  .overlay a {
    font-size: 20px;
  }
  .overlay .close {
    font-size: 40px;
    top: 15px;
    right: 35px;
  }
}

@media only screen and (max-width: 800px) {
  .nav__links,
  .cta {
    display: none;
  }
  .menu {
    display: initial;
  }
}

.right h1 {
  margin: 10px;
  padding: 10px;
  text-transform: uppercase;
  text-align: center;
  position: relative;
  top: 25%;
  transform: translateY(-50%);
  padding-top: 30px;
}

.right>* {
  text-align: center;
  justify-content: center;
  align-items: center;
  color: #ffffff;
  text-justify: center;
  text-align: center;
  margin: 10px;
}

.column {
  float: left;
  width: 50%;
  padding: 10px;
  height: 740px;
}

.row:after {
  content: "";
  display: table;
  clear: both;
}

@media screen and (max-width: 600px) {
  .column {
    width: 100%;
  }
}```
image

Ответы [ 3 ]

1 голос
/ 22 апреля 2020

Добро пожаловать!

Хорошо, поэтому, используя свойство z-index, мы можем изменить порядок отображения сверху, например:

```function openNav() {
  document.getElementById("mobile__menu").style.width = "100%";
}

function closeNav() {
  document.getElementById("mobile__menu").style.width = "0";
}```
   ``` * {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 30px 10%;
  background-color: #24252a;
  position: fixed;
  width: 100%;
  z-index: 1;
}

.logo {
  cursor: pointer;
}

.nav__links a,
.cta,
.overlay__content a {
  font-family: "Montserrat", sans-serif;
  font-weight: 500;
  color: #edf0f1;
  text-decoration: none;
}

.nav__links {
  list-style: none;
  display: flex;
}

.nav__links li {
  padding: 0px 20px;
}

.nav__links li a {
  transition: all 0.3s ease 0s;
}

.nav__links li a:hover {
  color: #0088a9;
}

.cta {
  padding: 9px 25px;
  background-color: rgba(0, 136, 169, 1);
  border: none;
  border-radius: 50px;
  cursor: pointer;
  transition: all 0.3s ease 0s;
}

.cta:hover {
  background-color: rgba(0, 136, 169, 0.8);
}```


/* Mobile Nav */

```.menu {
  display: none;
}

.overlay {
  height: 100%;
  width: 0;
  position: fixed;
  z-index: 1;
  left: 0;
  top: 0;
  background-color: #24252a;
  overflow-x: hidden;
  transition: all 0.5s ease 0s;
}

.overlay__content {
  display: flex;
  height: 100%;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.overlay a {
  padding: 15px;
  font-size: 36px;
  display: block;
  transition: all 0.3s ease 0s;
}

.overlay a:hover,
.overlay a:focus {
  color: #0088a9;
}

.overlay .close {
  position: absolute;
  top: 20px;
  right: 45px;
  font-size: 60px;
  color: #edf0f1;
}

@media screen and (max-height: 450px) {
  .overlay a {
    font-size: 20px;
  }
  .overlay .close {
    font-size: 40px;
    top: 15px;
    right: 35px;
  }
}

@media only screen and (max-width: 800px) {
  .nav__links,
  .cta {
    display: none;
  }
  .menu {
    display: initial;
  }
}

.right h1 {
  margin: 10px;
  padding: 10px;
  text-transform: uppercase;
  text-align: center;
  position: relative;
  top: 25%;
  transform: translateY(-50%);
  padding-top: 30px;
}

.right>* {
  text-align: center;
  justify-content: center;
  align-items: center;
  color: #ffffff;
  text-justify: center;
  text-align: center;
  margin: 10px;
}

.column {
  float: left;
  width: 50%;
  padding: 10px;
  height: 740px;
}

.row:after {
  content: "";
  display: table;
  clear: both;
}

@media screen and (max-width: 600px) {
  .column {
    width: 100%;
  }
}```
image

Итак, по умолчанию для z-index установлено значение 0, поэтому для элемента устанавливается z-index: 1; сделает этот «приоритет» упорядоченным поверх всего остального. Надеюсь, это поможет.

0 голосов
/ 22 апреля 2020

добавьте свой класс = "столбец справа" style = "z-index: -1";

image
0 голосов
/ 22 апреля 2020

Попробуйте добавить

z-index:1;

в заголовок

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...