skip to Main Content

I am writing this code, first webpage I have built. I have learning along the way but I have hit a block, I feel like it may be a simple block but in my ‘scallop’ H1 & P I can’t get them the align centre, they keep sitting to the left of my site. Can anybody see any faults I am missing?

.topnav {
  overflow: hidden;
  width: 100%;
  max-height: 100px;
  background-color: #e2bdf9;
}

.topnav a {
  color: #1a0342;
  text-align: center;
  display: inline-block;
  padding: 14px 16px;
  text-decoration: none;
  font-size: 17px;
  font-family: "Lilita One", cursive;
}

.topnav a:hover {
  background-color: #ddd;
  color: black;
}

.topnav a.active {
  background-color: rgb(255, 88, 5);
  color: white;
}

.TitleHeading {
  position: relative;
  max-width: 50%;
  max-height: 150px;
  left: -0.5px;
  bottom: 354px;
  background-color: rgb(9, 158, 123);
  color: white;
  padding-left: 20px;
  padding-right: 20%;
  padding-top: 100px;
  padding-bottom: 100px;
  float: left;
  width: 300px;
}

.firstbreak {
  width: 100%;
  height: 50px;
  border: none;
  background-color: #e2bdf9;
}

.scallop {
  position: relative;
  background: #e26464;
  padding: 50px;
}

.scallop h1 {
  position: relative;
  text-align: center;
  color: white;
  font-size: 35px;
  text-transform: uppercase;
  font-family: "PT Sans Narrow", sans-serif;
  line-height: 50px;
}

.scallop p {
  position: relative;
  text-align: center;
  color: white;
}

.scallop::after {
  position: absolute;
  bottom: -50px;
  left: 0px;
  width: 100%;
  content: " ";
  background: radial-gradient( circle at 50% 0%, #e26464 25%, #c4dcd1 26%, #c4dcd1 40%);
  background-color: #e26464;
  background-size: 50px 100px;
  height: 50px;
  background-repeat: repeat-x;
}

.after-scallop {
  background: #c4dcd1;
  padding: 50px;
  margin-bottom: 50px;
}

.after-scallop p {
  color: #9089c0;
  font-size: 25px;
  text-transform: none;
  font-family: "PT Sans Narrow", sans-serif;
  text-align: center;
  margin-top: 30px;
  font-weight: bold;
}

a {
  text-decoration: none;
}

img {
  margin-right: 20px;
}
<div class="topnav">
  <a class="active" href="#home">Home</a>
  <a href="#news">News</a>
  <a href="#contact">Contact</a>
  <a href="#about">About</a>
</div>
<div class="TitleImage">
  <img src="https://media.istockphoto.com/id/487671734/photo/contemporary-waiting-room-with-a-yellow-  armchair.jpg?s=1024x1024&w=is&k=20&c=zGLtlEtfidagJRuVx1SEkS3lkr_5IurCTTTOFb8uk-s=" alt="empty waiting room with a yellow arm chair" style="width: 100%"
    height="350px" />
  <div class="TitleHeading">
    <h1>THOUGHTFUL MINDS</h1>
    <h4>By Nicola</h4>
  </div>
</div>
<div class="firstbreak"></div>

<div id="Services">
  <div class="scallop">
    <h1>About Me</h1>
    <p>
      Being all of the above is a wild and fullfiling experiances in life which have lead me into a career in therapy. To get here I have exlpored my own path in life decisions I have made, oportunities taken and those that passed me by. I have found passion
      in helping others explore their journeys.
    </p>
  </div>
  <div class="after-scallop">
    <h2>Services I offer</h2>
    <br />
    <p style="color: #e26464; text-transform: uppercase; font-size: 20px">
      Tell all your friends and family
    </p>
    <p>
      <a href="" target="_blank">
        <img src="https://s3.mirror.co.uk/production/email/et/facebook-icon.png" border="0" alt="facebook-icon" width="40" />
      </a>
      <a href="" target="_blank">
        <img src="https://s3.mirror.co.uk/production/email/et/twitter-icon.png" border="0" alt="twitter-icon" width="40" />
      </a>
      <a href="" target="_blank">
        <img src="https://s3.mirror.co.uk/production/email/et/google-plus-icon.png" border="0" alt="googleplus-icon" width="40" />
      </a>
    </p>
  </div>
</div>

Can anyone identify where I have gone wrong?

2

Answers


  1. You need to change the position of the .scallop class to absolute. Then your scallop text will be center.

    Login or Signup to reply.
  2. The problem is with the float:left of the .TitleHeading element. It is moved out of the way, due to the bottom: 354px but the space it occupied initially is not, so it affects the following elements. I would suggest skipping the float completely and try to use flex/grid for structuring the layout of the page.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search