How to stop css from overlaying text

This may be a very stupid question, but how do I stop css from overlapping when I try to increase the font size?

@import url(https://fonts.googleapis.com/css?family=Fjalla+One);

html{
  height: 100%;
}

body{
  font-family: 'Fjalla One', sans-serif;
  background: #2C3E50;  /* fallback for old browsers */
  background: -webkit-linear-gradient(to top, #4CA1AF, #2C3E50);  /* Chrome 10-25, Safari 5.1-6 */
  background: linear-gradient(to top, #4CA1AF, #2C3E50); /* W3C, IE 10+/ Edge, Firefox 16+, Chrome 26+, Opera 12+, Safari 7+ */


}

.container{
  margin: auto;
}


h1{
  text-transform: uppercase;
  font-size: 60px;
  line-height: 47px;
  letter-spacing: 2px;
  text-shadow: #533d4a 1px 1px, #533d4a 2px 2px, #533d4a 3px 3px, #533d4a 4px 4px;
  text-align: center;
}

.title{
  transform: translateX(-50%) rotate(-5deg);
  display: block;
  margin-left:50%;
}
<body>
<!--Titel-->
  <section class="container">
  <h1>
    <br />
    <span class="title" >
       <label style="color:#e55643;">Burger</label><label style="color:#2b9f5e;">school</label>
    </span>
    <span class="title" style="color:#f1c83c;">afspraken</span>
  </h1>
</section>
</body>
Run codeHide result

Thanks for the help for the help. I just started like that again, maybe this is a very stupid question.

+4
source share
3 answers

You need to adjust line-height, for example. set it as font-sizein 60px. The text overlaps if it line-heightis small for the given font-size.

@import url(https://fonts.googleapis.com/css?family=Fjalla+One);
html {
  height: 100%;
}

body {
  font-family: 'Fjalla One', sans-serif;
  background: #2C3E50;
  /* fallback for old browsers */
  background: -webkit-linear-gradient(to top, #4CA1AF, #2C3E50);
  /* Chrome 10-25, Safari 5.1-6 */
  background: linear-gradient(to top, #4CA1AF, #2C3E50);
  /* W3C, IE 10+/ Edge, Firefox 16+, Chrome 26+, Opera 12+, Safari 7+ */
}

.container {
  margin: auto;
}

h1 {
  text-transform: uppercase;
  font-size: 60px;
  line-height: 60px;
  letter-spacing: 2px;
  text-shadow: #533d4a 1px 1px, #533d4a 2px 2px, #533d4a 3px 3px, #533d4a 4px 4px;
  text-align: center;
}

.title {
  transform: translateX(-50%) rotate(-5deg);
  display: block;
  margin-left: 50%;
}
<section class="container">
  <h1>
    <span class="title">
       <label style="color:#e55643;">Burger</label><label style="color:#2b9f5e;">school</label>
    </span>
    <span class="title" style="color:#f1c83c;">afspraken</span>
  </h1>
</section>
Run codeHide result
+3
source

You have installed in your code line-height : 47px;, but you are trying to increase the font size even more than the line height.

font-size: 60px;
line-height: 47px;  <!--This is what causing the problem, increase it as much as you increase the font size-->

For instance:

font-size: 60px;
line-height: 60px; <!--It will do the job-->
+1

line-height:47px;

+1

Source: https://habr.com/ru/post/1674996/


All Articles