简体   繁体   English

在标题中对齐段落文本

[英]Aligning Paragraph Text in Header

I'm coding my first website and I am having trouble aligning the intro text. 我正在编写第一个网站的代码,但无法对齐介绍文字。 Right now the paragraph is aligned to the left which is great, but I'm trying to have the text box be only the width of 625px and right now it's spanning the entire width of the page. 现在,该段落与左侧对齐,这很好,但是我试图使文本框的宽度仅为625像素,而现在它跨越了页面的整个宽度。 I tried to use padding to resolve it, but the text just remains the same width of the page. 我尝试使用填充来解决它,但是文本只是保持页面的相同宽度。 Below is my current code any help would be great! 以下是我当前的代码,任何帮助都将非常有用!

HTML: HTML:

<header class="masthead">
  <div class="container">
    <div class="intro-text">
        <p>"Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum. </p>
    </div>
  </div>
</header>

CSS: CSS:

header.masthead {
  text-align: left;
  color: white;
  background-image: url("../img/headshot.png");
  background-repeat: no-repeat;
  background-attachment: scroll;
  background-position: right;
  background-size: 500px 601px
}

header.masthead .intro-text p {
  padding-top: 50px;
  padding-bottom: 100px;
  padding-right: 500;
}

Do you want to align the 625px div in the middle of the page? 您要在页面中间对齐625px div吗? If so, do the following: 如果是这样,请执行以下操作:

.masthead .container {
    margin: 0 auto; // center the div
    max-width: 625px;
}

Now your child div and paragraph block elements will automatically take the max-width of 625px. 现在,您的子div和段落块元素将自动采用625px的最大宽度。

 header.masthead .intro-text p {
    padding-top: 50px;
    padding-bottom: 100px;
    padding-right: 500;

    width: 625px;
  }

add a width to you'r element. 为您的元素添加宽度。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM