Ash
Ash

Reputation: 51

When I scale the page, the text keeps overlapping over each other

I am trying to make a portfolio for an assignment and when I try to make the page window smaller, the text will overlap making it all messy. I once fixed this issue with min-width but I can't seem to fix it this time.

I can't get my head around why it keeps doing it, I am fairly "new" to HTML/CSS and lack the experience to fix this issue, if someone could help me resolve this I'd be grateful.

Thanks.

HTML

<head>
<title>CPD Portfolio - Home</title>
<meta charset="UTF-8">
<meta name="description" content="CPD Portfolio">
<meta name="author" content="Ashley Tanner-Mortell">
<meta name="viewport" content="width=device-width, inital=scale=1">
<link rel="stylesheet" href="stylesheet.css">
</head>

<body>
<ul>
  <li><a class="active" href="home_page.html">Home</a></li>
  <li><a href="university.html">University</a></li>
  <li><a href="sports.html">Sports</a></li>
  <li><a href="student_mentor.html">Student Mentor</a></li>
</ul>

<div id="gradient">

<div class="container">
    <img src="images/ntu1.jpg" style="width:100%; height:600px; object-fit:cover; border-style: solid; text-align: center;">
    <div class="centered" style="top:15%">CPD Portfolio</div>
    <div class="centered" style="top:20%;">_______________</div>
    <div class="centered" style="top:30%; font-size:6vh;">Ashley Tanner-Mortell</div>
</div>
</div>
</body>

<footer>
<p>Footer Details</p>
</footer>

</html>

CSS

body,html{
    margin: 0;
    min-width:500px;
}

footer {
  float: left;
  background-color: grey;
  padding: 0;
  width: 100%;
  text-align: center; 
  color: white; 
}

ul {
  list-style-type: none;
  margin: 0;
  padding: 0;
  overflow: hidden;
  background-image: linear-gradient(to right, silver, lightgrey);
}

li {
  list-style-type: none;
  float: left;
}

li a {
  list-style-type: none;
  display: block;
  color: white;
  text-align: center;
  padding: 14px 16px;
  text-decoration: none;
}

li a:hover:not(.active) {
  list-style-type: none;
  background-color: #E1E1DC;
}

.active {
  background-color: #00628B;
}

.container {
  margin: 0;
  color: white;
  font-size: 8vh; /*The vh is viewported by the height, use this for the scaling of text.*/
}

.centered {     
  position: absolute;
  top: 10%;
  left: 50%;
  transform: translate(-50%, -50%);
}

#gradient {
  height: 1300px;
  background-color: grey; /* For browsers that do not support gradients */
  background-image: linear-gradient(to right, silver, white); /* Standard syntax (must be last) */
}

.box1, .box2{
    border-style: solid;
    border-width: 1px;
    background-color: #F5F5F5;  
}

.box1{
   float: left; 
   width: 44vw;
   height: 400px;
   padding: 1vw;
   margin: 1vw;
}
.box2{
   float: left; 
   width: 44vw;
   height: 400px;
   padding: 1vw;
   margin: 1vw;
}

.box3{
   float: center;
   width: 90%;
}

Upvotes: 0

Views: 83

Answers (1)

Anshul Chaurasia
Anshul Chaurasia

Reputation: 100

Here you go, just replace below code HTML and CSS - Refer my comments for changed code.

CSS

body,html{
    margin: 0;
    min-width:500px;
}

footer {
  float: left;
  background-color: grey;
  padding: 0;
  width: 100%;
  text-align: center; 
  color: white; 
}

ul {
  list-style-type: none;
  margin: 0;
  padding: 0;
  overflow: hidden;
  background-image: linear-gradient(to right, silver, lightgrey);
}

li {
  list-style-type: none;
  float: left;
}

li a {
  list-style-type: none;
  display: block;
  color: white;
  text-align: center;
  padding: 14px 16px;
  text-decoration: none;
}

li a:hover:not(.active) {
  list-style-type: none;
  background-color: #E1E1DC;
}

.active {
  background-color: #00628B;
}

.container {
  margin: 0;
  color: white;
  font-size: 8vh; /*The vh is viewported by the height, use this for the scaling of text.*/
}

.centered {     
  position: absolute;
  top: 10px;
  left: 0;
  right:0;
  /* transform: translate(-50%, -50%); */
}

#gradient {
  height: 1300px;
  background-color: grey; /* For browsers that do not support gradients */
  background-image: linear-gradient(to right, silver, white); /* Standard syntax (must be last) */
}

.box1, .box2{
    border-style: solid;
    border-width: 1px;
    background-color: #F5F5F5;  
}

.box1{
   float: left; 
   width: 44vw;
   height: 400px;
   padding: 1vw;
   margin: 1vw;
}
.box2{
   float: left; 
   width: 44vw;
   height: 400px;
   padding: 1vw;
   margin: 1vw;
}

.box3{
   float: center;
   width: 90%;
}

/* added css for portfolio section */
.portfolioSection{
    padding-top: 100px;
    text-align: center
}
/* added css for portfolio heading */
.portfolioHead{
    border-bottom:1px solid #000;
    display: inline-block;
}

HTML

<ul>
                <li><a class="active" href="home_page.html">Home</a></li>
                <li><a href="university.html">University</a></li>
                <li><a href="sports.html">Sports</a></li>
                <li><a href="student_mentor.html">Student Mentor</a></li>
              </ul>

              <div id="gradient">

              <div class="container">
                  <img src="images/ntu1.jpg" style="width:100%; height:600px; object-fit:cover; border-style: solid; text-align: center;">
                  <!-- wrapped your divisions with parent devision for better control through out screens -->
                  <div class="centered portfolioSection">
                   <!-- added class to control heading styles -->
                    <div class="portfolioHead">CPD Portfolio</div>
                    <div style="font-size:6vh;">Ashley Tanner-Mortell</div>
                </div>
              </div>
              </div>
              </body>

              <footer>
              <p>Footer Details</p>
              </footer>

Also suggest you to go through this - https://www.w3.org/ and also youtube some free tutorial on HTML and CSS as i can see many basic issues in your css and html. :)

Upvotes: 2

Related Questions