简体   繁体   English

我如何使第一行文本缩进而又不影响其他所有内容?

[英]How do I make the first line of text indent without it throwing everything else off?

I would like to indent the text as I have done with the second heading WORK EXPERIENCE but if I apply this class to the first line 'EDUCATION' it throws out all my columns, how can I avoid this? 我想像在第二个标题“ WORK EXPERIENCE那样缩进文本,但是如果我将此类应用于第一行“ EDUCATION”,它将把我所有的列都扔掉,如何避免这种情况?

code: 码:

 .indent { text-indent: 70px; word-break: break-word; } 
 <div class="column"> <p>EDUCATION<br> 2014-18 Massey University Wellington, New Zealand. Bachelor of Design, Honours First Class. Visual Communication Design.<br></p> <div class="indent"> <p>WORK EXPERIENCE<br> </div> 

Close the p element after EDUCATION word and then the indentation will apply only to the heading line and not to all block of text. 在教育词后关闭p元素,然后缩进仅适用于标题行,而不适用于所有文本块。

<div class="column">
     <p class="indent">EDUCATION</p>
     <p>2014-18 Massey University
          Wellington, New Zealand.
          Bachelor of Design, Honours
          First Class. Visual Communication Design.<br></p>
      <div class ="indent">
      <p>WORK EXPERIENCE<br>
            </div>
<div class="column">
    <p class="indent">EDUCATION
        <br />
        2014-18 Massey University Wellington, New Zealand. Bachelor of Design, Honours First Class. Visual Communication
        Design.
        <br />
    </p>
    <div class="indent">
        <p>WORK EXPERIENCE</p>
    </div>
</div>

This will work and you will get output as 这将起作用,并且您将获得输出为 在此处输入图片说明

I guess, I am understanding your question correctly 我想,我正确理解了您的问题

If you want to use you markup you can wrap the indented text by your class. 如果要使用标记,则可以按类包装缩进的文本。

HTML 的HTML

    <div class="column">
        <p><span class="indent">EDUCATION</span>
            2014-18 Massey University Wellington, New Zealand. Bachelor of Design, Honours First Class. Visual Communication Design.
        </p>
        <p><span class="indent">WORK EXPERIENCE</span></p>
    </div>

CSS 的CSS

.indent{
    text-indent: 70px;
    display:block; /* Added to force the span acting as a block to avoid <br> tag*/
    /*word-break: break-word; I don´t think you need this property. */
}

My Suggestion 我的建议

<!-- The H3 heading it´s a suggestion, and you can always chose from the H1 -  H6 dependeng on your needs -->
<div class="column">
    <h3 class="indent">Education</h3> 
    <p>2014-18 Massey University Wellington, New Zealand. Bachelor of Design, Honours First Class. Visual Communication Design.</p>
    <h3 class="indent">Work Experience</h3>
    <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nulla tempus elit tellus, dapibus cursus orci.</p>
</div>

.indent{
    text-indent: 70px;
    text-transform:uppercase;
    display:block; /* This one is optional in the suggested markup.*/
}

Try this below. 请在下面尝试。 There is no need to use br tags instead you can add margin bottom to the p element. 无需使用br标签,而是可以在p元素上添加空白边距。 See the CSS class rules below. 请参阅下面的CSS类规则。

CSS 的CSS

.indent {
  text-indent: 70px;
  word-break: break-word;
  margin-bottom: 20px;
}

HTML 的HTML

<div class="column">
   <p class="indent">EDUCATION</p>
   <p>2014-18 Massey University Wellington, New Zealand. 
      Bachelor of Design, Honours First Class. Visual 
      Communication Design.
   </p>
</div>

JSFiddle sample link JSFiddle示例链接

https://jsfiddle.net/k1vjvkt7/

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

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