0

I have been working on a contact system - I got it to work, replies, everything - But the margins are way out of wack - see pic - Does anyone have any ideas what I am doing wrong? It is also centered and I want it to the left.

I have listed my index.php and styles.css below. I have to integrate it into an existing website - www.londonontariomortgages.ca/blog.html - So I am thinking of doing iFrame - However, with it not creating a new line when past the margin it looks dumb.

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;
}
m4n0
  • 29,823
  • 27
  • 76
  • 89
Mark Mitchell
  • 43
  • 1
  • 4
  • Can you post the html that forms after this php code runs in browser. That will help in figuring out this issue -> "with it not creating a new line when past the margin it looks dumb." – Nandita Sharma Jun 16 '18 at 14:26
  • Possible duplicate of [How to prevent long words from breaking my div?](https://stackoverflow.com/questions/320184/how-to-prevent-long-words-from-breaking-my-div) – Capricorn Jun 16 '18 at 15:07
  • Looks to me as this question is not about margins but the super-long words breaking the width of their containers... – Capricorn Jun 16 '18 at 15:08

1 Answers1

1

See updated CSS, I removed margin: auto from the .page-container and form.main and ".comment"

That was causing the centering of form on the page instead of default left alignment.

Add this CSS for fixing the text not wrapping issue

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

Your comments do not wrap because there is no space in them. So to break elements with no space in them, you need to add word-break: break-all property to break them explicitly.

In ideal world scenario, your comments will definitely have spaces in them and you wont need it(word-break), but the testers(testing your website ) will test it with any dummy data, so you need to be prepared for that and apply fix generally for this issue.

@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>
Nandita Sharma
  • 13,287
  • 2
  • 22
  • 35
  • Thank you! I appreciate it - However the comments are still not coming in at multiple lines - http://londonontariomortgages.ca/a/index.php - Would you mind taking a quick look? I am newbie at this stuff, thought I have come a long way in a week – Mark Mitchell Jun 16 '18 at 15:01
  • Add word-break: break-all; on comment-text .comment-text { font-size: 13px; line-height: 17px; color: #222; margin: 0px 10px; word-break: break-all; } See updated answer – Nandita Sharma Jun 16 '18 at 15:05
  • While this code may answer the question, providing additional context regarding why and/or how this code answers the question improves its long-term value. – Capricorn Jun 16 '18 at 15:08
  • @Capricorn thanks will do just now. Please give me some time. :) – Nandita Sharma Jun 16 '18 at 15:10
  • Thank you - I really appreciate all of the help - If I could trouble you for one more suggestion - I am hoping to have all of the comments straight down my page - so right under the text box - http://www.londonontariomortgages.ca/a/index.php - My eventual aim is to merge it into http://londonontariomortgages.ca/blog.html so that people can comment on the blog. Do you mind taking one more look? – Mark Mitchell Jun 16 '18 at 15:13
  • @MarkMitchell Remove margin: 0px auto; from the .comment div too and change the padding : 7px 23px to padding: 7px 0; – Nandita Sharma Jun 16 '18 at 15:25
  • basically margin: 0 auto; is centering everything horizontally on your page. If its not required dont use it – Nandita Sharma Jun 16 '18 at 15:28
  • @NanditaAroraSharma - Thanks so much!! That worked :) Now off to integrate - wish me luck :) – Mark Mitchell Jun 16 '18 at 15:35
  • @NanditaAroraSharma - Quick question with this field - if you a minute - I used iframe to merge it into my existing site - http://www.londonontariomortgages.ca/Blogs/blog_%20june_%2013/blog_june13_2018.html - but when I did the size of box and the comments shrunk to much lower - Do you know which line I would change in the css to fix this? I have the iframe set at 100% width – Mark Mitchell Jun 16 '18 at 16:38