无法正确获得我的边距

时间:2018-06-16 14:11:38

标签: php css

我一直在研究一个联系系统 - 我得到它的工作,回复,一切 - 但边缘是出于怪癖 - 见图片 - 有没有人有任何想法我做错了什么?它也是居中的,我想要它在左边。

我在下面列出了我的index.php和styles.css。我必须将它整合到一个现有的网站 - www.londonontariomortgages.ca/blog.html - 所以我在考虑做iFrame - 但是,当它超过边距时它没有创建一个新的线条它看起来很愚蠢。

enter image description here

的index.php

<?php require_once 'php/connect.php'; require_once 'php/functions.php'; ?>
<!doctype html>
<html>
    <head>
        <title>YouTube Comment System Series</title>
        <meta charset="UTF-8" lang="en-US">
        <link rel="stylesheet" href="style.css">
        <script src="https://code.jquery.com/jquery-3.0.0.min.js"></script>
        <script src="js/global.js"></script>
    </head>
    <body>

        <p>
        <div class="page-container">
            <?php 
                get_total();
                require_once 'php/check_com.php';
            ?>
            <form action="" method="post" class="main">
                <label>enter a brief comment</label>
                <textarea class="form-text" name="comment" id="comment"></textarea>
                <br />
                <input type="submit" class="form-submit" name="new_comment" value="post">
            </form>
            <?php get_comments(); ?>
        </div>
    </p>
    </body>
</html>

styles.php

@import url(https://fonts.googleapis.com/css?family=Open+Sans:300,400,600,700);

/* resets */
* {
    margin:0px;
    padding:0px;
    box-sizing:border-box;
    font-family:'Calibri', sans-serif;
    outline:none;
}

/* Animations */
@keyframes shake {
  10%, 90% {
    transform: translate3d(-1px, 0, 0);
  }
  20%, 80% {
    transform: translate3d(2px, 0, 0);
  }
  30%, 50%, 70% {
    transform: translate3d(-4px, 0, 0);
  }
  40%, 60% {
    transform: translate3d(4px, 0, 0);
  }
}

/* body, html */
html, body {
    background-color:#edf1f5;
}

/* content */
.page-container {
    width:80%;
    height:auto;
    min-height:100vh;
    margin:0 auto;
    padding:50px 10px 0px 10px;
}
.comment {
    width:45%;
    height:auto;
    padding:7px 23px;
    margin:0px auto;
    margin-bottom:10px;
    text-align:left;
}
.child {
    margin-top:10px;
    margin-left:30px;
    padding-left:5px;
}
.child-comments {
    border-left:1px solid rgba(1,1,1,0.2);
}

form.main {
    width:45%;
    margin:0 auto;
    margin-top:5px;
}
    .form-input {
        border:1px solid rgba(1,1,1,0.3);
        width:50%;
        padding:4px 7px;
        font-size:13px;
        line-height:24px;
        resize:none;
    }
    .form-text {
        border:1px solid rgba(1,1,1,0.3);
        width:100%;
        padding:4px 7px;
        margin-top:5px;
        font-size:13px;
        line-height:24px;
        resize:none;
        transition:ease 0.2s all;
        outline:none !important;
    }
        .form-text-error {
            border-color:rgba(237,28,36,0.7);
            animation: shake 0.82s cubic-bezier(.36,.07,.19,.97) both;
            transform: translate3d(0, 0, 0);
            backface-visibility: hidden;
            perspective: 1000px;
        }
        .form-text:focus {
            border-color:rgba(0,114,188,0.7);
        }
    .form-submit {
        text-transform: uppercase;
        border:1px solid rgba(1,1,1,0.3);
        cursor:pointer;
        padding:5px 13px;
        margin-top:5px;
    }

/* fonts */
.user, .time {
    display:inline-block;
}
.user {
    font-size:13px;
    color:#0072bc;
    text-decoration: none;
    word-break: break-all;
    line-height:17px;
}
.time {
    font-size:11px;
    color:#b2b1b1;
    transition:ease 0.2s all;
}
    .comment:hover .time {
        color:#767676;
    }
.comment-text {
    font-size:13px;
    line-height:17px;
    color:#222;
    margin:0px 10px;
}
a {
    font-size:11.2px;
    text-transform: uppercase;
    text-decoration: none;
    color:#222;
    cursor:pointer;
    transition:ease 0.3s all;
}
a:hover {
    color:#0072bc;
}
    .link-reply {
        color:#767676;
        margin-left:20px;
    }

h1 {
    width:45%;
    height:auto;
    margin:0px auto;
    font-size:16px;
    font-weight:300;
    text-transform: uppercase;
    border-bottom:1px solid rgba(1,1,1,0.2);
}

label {
    font-size:13px;
    text-transform: uppercase;
    vertical-align: bottom;
}

1 个答案:

答案 0 :(得分:1)

查看更新后的CSS,我从margin: auto.page-container以及“.comment”中删除了form.main

这导致页面上的窗体居中而不是默认左对齐。

添加此CSS以修复未包装问题的文本

.comment-text {
    font-size: 13px;
    line-height: 17px;
    color: #222;
    margin: 0px 10px;
    word-break: break-all;
}

您的评论不会换行,因为其中没有空格。因此,要破坏其中没有空格的元素,您需要添加word-break: break-all属性以明确区分它们。

在理想的世界场景中,你的评论肯定会有空格,你不会需要它(断字),但测试人员(测试你的网站)会用任何虚拟数据测试它,所以你需要做好准备一般来说这个问题并适用于此问题。

@import url(https://fonts.googleapis.com/css?family=Open+Sans:300,400,600,700);

/* resets */

* {
  margin: 0px;
  padding: 0px;
  box-sizing: border-box;
  font-family: 'Calibri', sans-serif;
  outline: none;
}


/* Animations */

@keyframes shake {
  10%,
  90% {
    transform: translate3d(-1px, 0, 0);
  }
  20%,
  80% {
    transform: translate3d(2px, 0, 0);
  }
  30%,
  50%,
  70% {
    transform: translate3d(-4px, 0, 0);
  }
  40%,
  60% {
    transform: translate3d(4px, 0, 0);
  }
}


/* body, html */

html,
body {
  background-color: #edf1f5;
}


/* content */

.page-container {
  width: 80%;
  height: auto;
  min-height: 100vh;
  padding: 20px 10px 0px 10px;
}

.comment {
  width: 45%;
  height: auto;
  padding: 7px 0;
  margin-bottom: 10px;
  text-align: left;
}

.child {
  margin-top: 10px;
  margin-left: 30px;
  padding-left: 5px;
}

.child-comments {
  border-left: 1px solid rgba(1, 1, 1, 0.2);
}

form.main {
  width: 45%;
  margin-top: 5px;
}

.form-input {
  border: 1px solid rgba(1, 1, 1, 0.3);
  width: 50%;
  padding: 4px 7px;
  font-size: 13px;
  line-height: 24px;
  resize: none;
}

.form-text {
  border: 1px solid rgba(1, 1, 1, 0.3);
  width: 100%;
  padding: 4px 7px;
  margin-top: 5px;
  font-size: 13px;
  line-height: 24px;
  resize: none;
  transition: ease 0.2s all;
  outline: none !important;
}

.form-text-error {
  border-color: rgba(237, 28, 36, 0.7);
  animation: shake 0.82s cubic-bezier(.36, .07, .19, .97) both;
  transform: translate3d(0, 0, 0);
  backface-visibility: hidden;
  perspective: 1000px;
}

.form-text:focus {
  border-color: rgba(0, 114, 188, 0.7);
}

.form-submit {
  text-transform: uppercase;
  border: 1px solid rgba(1, 1, 1, 0.3);
  cursor: pointer;
  padding: 5px 13px;
  margin-top: 5px;
}


/* fonts */

.user,
.time {
  display: inline-block;
}

.user {
  font-size: 13px;
  color: #0072bc;
  text-decoration: none;
  word-break: break-all;
  line-height: 17px;
}

.time {
  font-size: 11px;
  color: #b2b1b1;
  transition: ease 0.2s all;
}

.comment:hover .time {
  color: #767676;
}

.comment-text {
  font-size: 13px;
  line-height: 17px;
  color: #222;
  margin: 0px 10px;
}

a {
  font-size: 11.2px;
  text-transform: uppercase;
  text-decoration: none;
  color: #222;
  cursor: pointer;
  transition: ease 0.3s all;
}

a:hover {
  color: #0072bc;
}

.link-reply {
  color: #767676;
  margin-left: 20px;
}

h1 {
  width: 45%;
  height: auto;
  margin: 0px auto;
  font-size: 16px;
  font-weight: 300;
  text-transform: uppercase;
  border-bottom: 1px solid rgba(1, 1, 1, 0.2);
}

label {
  font-size: 13px;
  text-transform: uppercase;
  vertical-align: bottom;
}
<html>

<head>
  <title>YouTube Comment System Series</title>
  <meta charset="UTF-8" lang="en-US">
  <link rel="stylesheet" href="style.css">
  <script src="https://code.jquery.com/jquery-3.0.0.min.js"></script>
  <script src="js/global.js"></script>
</head>

<body>

  <p>
    <div class="page-container">
      <?php 
                get_total();
                require_once 'php/check_com.php';
            ?>
      <form action="" method="post" class="main">
        <label>enter a brief comment</label>
        <textarea class="form-text" name="comment" id="comment"></textarea>
        <br />
        <input type="submit" class="form-submit" name="new_comment" value="post">
      </form>
      <?php get_comments(); ?>
    </div>
  </p>
</body>

</html>