форматирование текста в нижнем колонтитуле (текст под значками) - PullRequest
1 голос
/ 29 мая 2020

Мне нужна помощь в форматировании нижнего колонтитула моего веб-сайта. Я новичок в CSS, и я не могу понять, как сделать так, чтобы текст для авторских прав располагался под значками. Я попробовал настроить, изменив высоту нижнего колонтитула, и лучшее, что я смог получить, - это текст слева или справа от значков. Любая помощь будет принята с благодарностью.

CSS Таблица стилей:

body {
    margin: 0;
}

.logo {
    display: block;
    margin-left: auto;
    margin-right: auto;
    width: 50px;
    height: 50px;
    margin-top: 11px;
}

.navBar {
    display: flex;
    justify-content: center;
    overflow: hidden;
    background-color: white;
    position: fixed;
    top: 0;
    width: 100%;
    margin-top: 61px;
    text-align: center;
}

.navBar a {
    display: inline-block;
    width: 10%;
    color: black;
    text-align: center;
    padding: 7px 7px;
    text-decoration: none;
    font-size: 17px;
    font-family: "Poppins";
}

body.services a.services,
body.ourstory a.ourstory {
    border-bottom: 1.5px solid black;
}

.header {
    position: fixed;
    background-color: white;
    width: 100%;
    height: 80px;
}

.p3 {
    color: black;
    text-align: center;
    font-family: 'Poppins';
    font-size: 105%;
    font-weight: 300;
    line-height: 1.8em;
}
.p4 {
    color: black;
    text-align: center;
    padding-left: 200px;
    font-family: 'Poppins';
    font-size: 100%;
    font-weight: 300;
    line-height: 1.8em;
}

HTML Документ:

.content {
  padding: 10.4%;
}

.main {
  height: 800px;
  background-color: #f9f9f9;
}

.copyright {
  color: black;
  text-align: center;
  font-family: 'Poppins';
  font-size: 70%;
  font-weight: 300;
  line-height: 1.8em;
  display: block;
  margin-bottom: 100px;
}

.navbarSocialMedia {
  display: flex;
  justify-content: center;
  overflow: hidden;
  background-color: white;
  position: fixed;
  bottom: 0;
  width: 100%;
  text-align: center;
}

.newFooter {
  position: fixed;
  background-color: white;
  width: 100%;
  height: 800px;
}

.navbarSocialMedia a {
  display: inline-block;
  width: 3.5%;
  color: black;
  text-align: center;
  padding: 5px 5px;
  text-decoration: none;
  font-size: 17px;
  font-family: "Poppins";
}

.mediaLogo {
  display: block;
  margin-left: auto;
  margin-right: auto;
  width: 21px;
  height: 21px;
  margin-top: 10px;
  margin-bottom: 10px;
}
<!DOCTYPE html>
<html lang="en-US">
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">

<head>

<title>Giving Back</title>

    <link href="simpleCSS.css" rel="stylesheet" type="text/css">
    <link href='https://fonts.googleapis.com/css?family=Poppins' rel='stylesheet'>
    <link rel="shortcut icon" type="image/png" href="name.png">

    </head>

    <body class="services">

    <div class="header">

        <a href="simple.html">
            <img src="name.png" alt="Logo" class="logo"> </a>

        <div class="navBar">
            <a href="ourstory.html" class="ourstory">Our Story</a>
            <a href="services.html" class="services">Giving Back</a>
        </div>

    </div>

    <br>
    <br>
    <br>

    <div class="main">
        <div class="content">

            <p class="p3"> content

            </p>
        </div>
    </div>

    <div class="newFooter">
        <div class="navbarSocialMedia">
            <a href="https://www.instagram.com/" target="_blank">
                <img src="InstagramLogo48.png " alt="email logo" class="mediaLogo"> </a>
            <a href="https://www.linkedin.com" target="_blank">
                <img src="linkedin48.png " alt="linked in logo" class="mediaLogo"> </a>
            <a href="//www.google.com" target="_blank">
                <img src="emaillogo48.png " alt="email logo" class="mediaLogo"> </a>
            <a href="https://www.facebook.com " target="_blank">
                <img src="facebooklogo48.png " alt="facebook logo" class="mediaLogo"> </a>
        </div>

        <div class="try">
            <p class=" copyright ">Copyright &copy. </p>
    </div>
    </div>
    </body>
    </html>

Ответы [ 3 ]

0 голосов
/ 29 мая 2020

Причина, по которой div об авторских правах не отображается, заключается в том, что ваш <div class="navbarSocialMedia"> имеет фиксированную позицию, поэтому он отображается поверх нижнего колонтитула (который также имеет фиксированное положение).

An элемент с position: fixed; позиционируется относительно области просмотра, что означает, что он всегда остается на том же месте, даже если страница прокручивается. w3

Я установил атрибуты bottom: 0; left: 0; right: 0; нижнего колонтитула, чтобы он отображался в нижней части окна и с полной шириной.

Также я бы предложил удалить margin-bottom: 100px из <p class="copyright">, так как это занимает слишком много места из окна.

И последнее, но не менее важное: я заметил, что для <div class="navbarSocialMedia"> вы установили text-align: center (так что я предполагаю вы хотите, чтобы значки располагались по центру), но поскольку у него есть свойство display: flex. Вместо этого лучше использовать align-items: center.

Надеюсь, это вам поможет.

.content {
  padding: 10.4%;
}

.main {
  height: 800px;
  background-color: #f9f9f9;
}

.copyright {
  color: black;
  text-align: center;
  font-family: 'Poppins';
  font-size: 70%;
  font-weight: 300;
  line-height: 1.8em;
  display: block;
}

.navbarSocialMedia {
  display: flex;
  justify-content: center;
  overflow: hidden;
  background-color: white;
  width: 100%;
  align-items: center;
}

.newFooter {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background-color: white;
  width: 100%;
}

.navbarSocialMedia a {
  display: inline-block;
  width: 3.5%;
  color: black;
  text-align: center;
  padding: 5px 5px;
  text-decoration: none;
  font-size: 17px;
  font-family: "Poppins";
}

.mediaLogo {
  display: block;
  margin-left: auto;
  margin-right: auto;
  width: 21px;
  height: 21px;
  margin-top: 10px;
  margin-bottom: 10px;
}
<!DOCTYPE html>
<html lang="en-US">
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">

<head>

<title>Giving Back</title>

    <link href="simpleCSS.css" rel="stylesheet" type="text/css">
    <link href='https://fonts.googleapis.com/css?family=Poppins' rel='stylesheet'>
    <link rel="shortcut icon" type="image/png" href="name.png">

    </head>

    <body class="services">

    <div class="header">

        <a href="simple.html">
            <img src="name.png" alt="Logo" class="logo"> </a>

        <div class="navBar">
            <a href="ourstory.html" class="ourstory">Our Story</a>
            <a href="services.html" class="services">Giving Back</a>
        </div>

    </div>

    <br>
    <br>
    <br>

    <div class="main">
        <div class="content">

            <p class="p3"> content

            </p>
        </div>
    </div>

    <div class="newFooter">
        <div class="navbarSocialMedia">
            <a href="https://www.instagram.com/" target="_blank">
                <img src="InstagramLogo48.png " alt="email logo" class="mediaLogo"> </a>
            <a href="https://www.linkedin.com" target="_blank">
                <img src="linkedin48.png " alt="linked in logo" class="mediaLogo"> </a>
            <a href="//www.google.com" target="_blank">
                <img src="emaillogo48.png " alt="email logo" class="mediaLogo"> </a>
            <a href="https://www.facebook.com " target="_blank">
                <img src="facebooklogo48.png " alt="facebook logo" class="mediaLogo"> </a>
        </div>

        <div class="try">
            <p class=" copyright ">Copyright &copy. </p>
    </div>
    </div>
    </body>
    </html>
0 голосов
/ 29 мая 2020

добавлен красный фон в нижний колонтитул, чтобы идентифицировать элемент нижнего колонтитула. Вы можете изменить позже.

.content {
  padding: 10.4%;
}

.main {
  height: 800px;
  background-color: #f9f9f9;
}

.copyright {
  color: black;
  text-align: center;
  font-family: 'Poppins';
  font-size: 70%;
  font-weight: 300;
  line-height: 1.8em;
  display: block; 
}

.navbarSocialMedia {
  display: flex;
  justify-content: center;
  overflow: hidden;
  background-color: red; 
  bottom: 0;
  width: 100%;
  text-align: center;
}

.newFooter {
  position: fixed;
  background-color: white;
  width: 100%;
  height: 800px;
}

.navbarSocialMedia a {
  display: inline-block;
  width: 3.5%;
  color: black;
  text-align: center;
  padding: 5px 5px;
  text-decoration: none;
  font-size: 17px;
  font-family: "Poppins";
}

.mediaLogo {
  display: block;
  margin-left: auto;
  margin-right: auto;
  width: 21px;
  height: 21px;
  margin-top: 10px;
  margin-bottom: 10px;
}

.try {
  position: absolute;
  width: 100%;
  color: #fff;
  line-height: 40px;
  font-size: 0.7em;
  text-align: center;
  bottom: 0;
}

.footer {
  position: fixed;
  left: 0;
  bottom: 0;
  width: 100%;
  background-color: red;
  color: white;
  text-align: center;
}
<!DOCTYPE html>
<html lang="en-US">
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">

<head>

  <title>Giving Back</title>

  <link href="simpleCSS.css" rel="stylesheet" type="text/css">
  <link href='https://fonts.googleapis.com/css?family=Poppins' rel='stylesheet'>
  <link rel="shortcut icon" type="image/png" href="name.png">
  <link href="https://stackpath.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet" integrity="sha384-wvfXpqpZZVQGK6TAh5PVlGOfQNHSoD2xbE+QkPxCAFlNEevoEH3Sl0sibVcOQVnN" crossorigin="anonymous">
</head>

<body class="services">

  <div class="header">

    <a href="simple.html">
      <img src="name.png" alt="Logo" class="logo"> </a>

    <div class="navBar">
      <a href="ourstory.html" class="ourstory">Our Story</a>
      <a href="services.html" class="services">Giving Back</a>
    </div>

  </div>

  <br>
  <br>
  <br>

  <div class="main">
    <div class="content">

      <p class="p3"> content

      </p>
    </div>
  </div>



  <div class="footer">
    <div class="navbarSocialMedia">
      <a href="https://www.instagram.com/" target="_blank">
        <i class="fa fa-instagram"></i></a>
      <a href="https://www.linkedin.com" target="_blank">
        <i class="fa fa-linkedin"></i> </a>
      <a href="//www.google.com" target="_blank">
        <i class="fa fa-google"></i></a>
      <a href="https://www.facebook.com " target="_blank">
        <i class="fa fa-facebook"></i> </a>
    </div>
    <p class=" copyright ">Copyright &copy;. </p>
  </div>
</body>

</html>
0 голосов
/ 29 мая 2020

Изменение кода на .copyright и .navbarSocialMedia CSS. В основном, чтобы изменить положение на .copyright и выровнять нижнюю часть .navbarSocialMedia.

.content {
  padding: 10.4%;
}

.main {
  height: 800px;
  background-color: #f9f9f9;
}

.copyright {
  color: black;
  text-align: center;
  font-family: 'Poppins';
  font-size: 70%;
  font-weight: 300;
  line-height: 1.8em;
  /* display: block;*/
  /* Add fixed position */
  position: fixed;
  bottom: 0;
  left: 50%;
  /* margin-bottom: 100px; */
}

.navbarSocialMedia {
  display: flex;
  justify-content: center;
  overflow: hidden;
  background-color: white;
  position: fixed;
  bottom: 2.5em; /* Change to 2.5em for the copyright space */
  width: 100%;
  text-align: center;
}

.newFooter {
  position: fixed;
  background-color: white;
  width: 100%;
  height: 800px;
}

.navbarSocialMedia a {
  display: inline-block;
  width: 3.5%;
  color: black;
  text-align: center;
  padding: 5px 5px;
  text-decoration: none;
  font-size: 17px;
  font-family: "Poppins";
}

.mediaLogo {
  display: block;
  margin-left: auto;
  margin-right: auto;
  width: 21px;
  height: 21px;
  margin-top: 10px;
  margin-bottom: 10px;
}
<!DOCTYPE html>
<html lang="en-US">
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">

<head>

  <title>Giving Back</title>

  <link href="simpleCSS.css" rel="stylesheet" type="text/css">
  <link href='https://fonts.googleapis.com/css?family=Poppins' rel='stylesheet'>
  <link rel="shortcut icon" type="image/png" href="name.png">

</head>

<body class="services">

  <div class="header">

    <a href="simple.html">
      <img src="name.png" alt="Logo" class="logo"> </a>

    <div class="navBar">
      <a href="ourstory.html" class="ourstory">Our Story</a>
      <a href="services.html" class="services">Giving Back</a>
    </div>

  </div>

  <br>
  <br>
  <br>

  <div class="main">
    <div class="content">

      <p class="p3"> content

      </p>
    </div>
  </div>

  <div class="newFooter">

    <div class="navbarSocialMedia">
      <a href="https://www.instagram.com/" target="_blank">
        <img src="InstagramLogo48.png " alt="email logo" class="mediaLogo"> </a>
      <a href="https://www.linkedin.com" target="_blank">
        <img src="linkedin48.png " alt="linked in logo" class="mediaLogo"> </a>
      <a href="//www.google.com" target="_blank">
        <img src="emaillogo48.png " alt="email logo" class="mediaLogo"> </a>
      <a href="https://www.facebook.com " target="_blank">
        <img src="facebooklogo48.png " alt="facebook logo" class="mediaLogo"> </a>
    </div>

    <div class="try">
      <p class=" copyright ">Copyright &copy. </p>
    </div>
  </div>
</body>

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