When the text starts to overlap the column completely at approximately 700 pixels wide

Previously, everything was working fine until it suddenly broke. The column system switches to a 100% width single column at 1500px, but for some reason, the text overflows off the screen around 700px and I can't figure out why. The text at the bottom and the navbar are functioning correctly, but there seems to be an issue with the text breaking.

URL: liammacalister.com

<!DOCTYPE html>
<html lang="en">
    
<head>
    <meta charset="utf-8"/>    
    
    <meta name="viewport" content="width=device-width, initial-scale=1.0"/>
    
    <link rel="stylesheet" href="homeStyle.css">

    <title>Liam Macalister - Home</title>
    
</head>
    <div class="header">
        <h1>Liam Macalister - Portfolio</h1>
    </div>

    <ul class="topnav">
        <li><a href="#header">Home</a></li>
        <li><a href="#aboutContent">About Me</a></li>
        <li><a href="#unityContent">Unity</a></li>
        <li><a href="#unrealContent">Unreal</a></li>
        <li><a href="#cvContent">CV</a></li>
        <li><a href="#footer">Contact</a></li>
    </ul>

    <div class="row">
        <div class="column">
            <h2>Left Text</h2>
            <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Phasellus ac consequat velit...
                (Text truncated for brevity)
            </p>
        </div>
        <div class="column">
            <img class="imgMe" src="Me.jpg" alt="Me">               
        </div>
        <div class="column">
            <h2>Right Text</h2>
            <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Phasellus ac consequat velit...
                (Text truncated for brevity)
            </p>
        </div>
    </div>  

    <div id ="aboutContent" class="aboutContent">
        <h2> Second Text</h2>
        <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Phasellus ac consequat velit...
            (Text truncated for brevity)
        </p>
    </div>
    <div id ="unityContent" class="unity">
        
    </div>
    <div id ="unrealContent" class="unreal">
    </div>

    <div id ="cvContent" class="cv">
    </div>

    <div id="footer" class="footer">
        <h2>Contact</h2>
    </div>
</body>
</html>

CSS:

* {
  box-sizing: border-box;
}

@font-face{
  font-family: PermanentMarker;
  src:URL('PermanentMarker.ttf') format('truetype');
}

html {
  scroll-behavior: smooth;
}

body{
  margin: 0;
}

.header {
  font-family: PermanentMarker;
  font-size: 28px;
  padding: 20px;
  text-align: center;
}

h2 {
  font-family: PermanentMarker;
}

ul.topnav {
  list-style-type: none;
  margin: 0;
  padding: 0;
  overflow: hidden;
  background-color: #333;
}

ul.topnav li {float: left;}

ul.topnav li a {
  display: block;
  color: white;
  text-align: center;
  padding: 14px 16px;
  text-decoration: none;
}

ul.topnav li a:hover {background-color: #111;}

ul.topnav li.right {float: right;}

.column {
  float: left;
  width: 33.33%;
  padding: 15px;
  /*font-size: 18px;*/
}

p{
  font-family: Arial, Helvetica, sans-serif;
}
.row {
  content:"";
  display: table;
  clear: both;
}

.imgMe{
  padding-top: 30px;
  display: block;
  margin-right: auto;
  margin-left: auto;
}

.aboutContent{
  padding: 15px;
}

.footer {
  background-color: black;
  color: white;
  text-align: center;
  padding: 10px;
}

@media screen and (max-width: 2000px){
  .column{
    width: 50%;
  }
}

@media screen and (max-width: 1500px){
  .column{
    width: 100%;
  }
}

@media screen and (max-width: 600px){
  ul.topnav li.right, 
  ul.topnav li {float: none;
  }
  .column{
    width: 100%;
  }
}

Any advice?

Answer №1

If you're looking to avoid using floats and display: table, consider using flex instead. It can provide a cleaner solution with more flexibility.

Here's an example layout:

<div class="container">
    <div class="row">
      <div class="col">
        <p>Text on the LEFT</p>
      </div>
      <div class="col">
        <img src="example.jpg" alt="">
      </div>
    </div>
    <div class="row-reverse">
      <div class="col">
        <p>Text on the RIGHT</p>
      </div>
    </div>
  </div>

You can apply the following CSS rules to style this layout:

.container {
  padding: 0 15px;
  margin: 0 auto;
  max-width: 1400;
}
.row {
  display: flex;
  height: 100%;
}
.row-reverse {
  display: flex;
  flex-direction: row-reverse;
}
.col {
  height: 100%;
  width: 50%;
  border: solid green;
}
img {
  width: 100%;
  height: auto;
}

@media screen and (max-width: 600px) {
  .row {
    display: block;
  }
  .col {
    width: 100%;
  }
}

For a different layout, you could also try:

<div class="container">
      <div class="row">
        <div class="col">
          <p>Text on the LEFT</p>
        </div>
     <div class="col">
          <img src="another-example.jpg" alt="">
       </div>
        <div class="col">
          <p>Text on the RIGHT</p>
        </div>
      </div>
    </div>

Don't forget to add the base styles at the top of your CSS file:

* {
  margin: 0;
  padding: 0;
}

Adjust the widths and media queries for .col to suit your specific needs.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Purchase Now with Paypal Button

Just starting out with PHP and PayPal buttons! Important: Referring to Mysql items here. I'm attempting to set up an online shop, but I have a concern about PayPal "Buy Now" buttons. If a customer purchases an item, the website receives the money, b ...

Does CSS media query "@media only screen" only work when I am resizing the window?

I recently encountered an issue with the code found on this website (the repository can be viewed on Github here): @media only screen and (max-width: 600px) { img {width: 100%; height: 100%; margin: 0; padding: 0; } a.box { width: 100%; pa ...

Can a list be transformed into a toolbar in a responsive design?

Here is my card with a nav section that includes multiple items (although I've only included one here for simplicity). <div class="col-md-3"> <div class="card"> <div class="card-header"> ...

CSS: border-radius // background-color: white; rounded corners

Having recently delved into the world of HTML/CSS, I am currently working on a fun project to enhance my web development skills. In this project, I have created a search bar and successfully added round corners with border-radius. However, an issue arises ...

Error during compilation due to a missing parenthesis in the loop structure

I've been experimenting with creating a carousel using just html and css, without any Javascript. I've been exploring resources on the web and following tutorials to achieve this goal. However, I've encountered an issue. I created a mixin l ...

Javascript enables dynamic field addition to tables

I have JSON data that needs to be displayed in an HTML table. To input the values, I have individual fields for firstname, lastname, email, and phone number, along with an "Add Row" button. When I click the "Add Row" button, I want the entered values to b ...

Is there a way to customize the hover effect on this navigation link in Bootstrap that includes a span and an icon from Bootstrap?

<li class="nav-item mt-3"> <a href="#" class="nav-link px-2 d-flex justify-content-start align-items-center"> <i class="nav-icon bi bi-calculator-fill fs-4"></i> ...

unable to expand navbar in Angular 5 project with Bootstrap 4

I am encountering an issue with my navigation bar in a project that uses Angular5 and Bootstrap4. The navigation bar is supposed to expand when the screen size is small, as indicated by the navbar-expand-sm class in Bootstrap4. However, the navbar remains ...

best way to display an array in HTML

When I input a manufacturer, I want to display the complete data from each object inside the array in the HTML. However, when I call the function on the HTML page, all I get back is the word object repeated as many times as the Manufacturer is defined in ...

Adjusting the gaps between each item in a list

Currently, I am working on developing a minimalist single-page website. However, I am facing challenges with spacing in the navbar section (as demonstrated below). When using an unordered list, everything looks good until the list overlaps with the centra ...

Conceal button divider on pager in Jqgrid

Within my grid setup, there are 3 buttons placed in the pager section: 'Refresh', 'Constution', and 'Developed'. These buttons are separated by two vertical navSeparators. Upon grid load, the 'Developed' button is hi ...

After encountering a character with CSS, begin a new line

I have a CSV spreadsheet with data that looks like this: <p>Features:• first feature• second feature• third feature• fourth feature• and so on (the total number of features is variable)</p> I want each feature to display on a new li ...

Unable to display information from a repeated `textarea` in ngRepeat

Check out my code on Plunker: https://plnkr.co/edit/rBGQyOpi9lS0QtnCUq4L I'm trying to log the content of each textarea when typing, using the printStuff() function: $scope.printStuff = function(customize, item) { console.log(customize[item.inde ...

Sharing HTML code from R to your Wordpress posts

I have successfully created an RMarkdown file that generates a visually appealing HTML page. You can view the output here: Now, my goal is to embed this HTML code onto our Wordpress site at: The challenge I'm facing is getting the content onto the p ...

Learn how to retrieve images from the web API at 'https://jsonplaceholder.typicode.com/photos' and showcase them on a webpage using Angular10

Using the API "https://jsonplaceholder.typicode.com/photos", I have access to 5 properties: albumId: 1 id: 1 thumbnailUrl: "https://via.placeholder.com/150/92c952" title: "accusamus beatae ad facilis cum similique qui sunt" url: "https://via.placeh ...

Error encountered: $(...).pickadate is not defined as a function

I am currently working on a basic web project that involves a simple form where users enter their name, birthday, and university degree. I am utilizing Materialize and jQuery for this project. However, I have encountered a frustrating issue while trying to ...

JavaScript: Can you clarify the value of this variable using five sets of double quotations?

Could you please review the code snippet below for me? <script type="text/javascript"> function recentpostslist(json) { document.write('<ul class="recommended">'); var i; var j; for (i = 0; i < json.feed.entry.length; i++) { ...

Switching out CSS files on the fly in ASP.NET

Looking to dynamically change the CSS file being used in my ASP.NET Web Application when it's running. Imagine I have two CSS files, red.css and blue.css. I attempted the following method: In the Master Page, I have this link: <link rel="Styles ...

creating a mixin for a box-shadow value of none in LESS CSS

I'm encountering a challenge with implementing the box-shadow mixin in LESS css. Here's the mixin for box-shadow: .boxShadow (@x, @y, @blur, @spread: 0, @alpha) { -webkit-box-shadow: @x @y @blur @spread rgba(0, 0, 0, @alpha); -moz-box-s ...

html2canvas encountered a CORS error when trying to retrieve images from an external domain

I have been attempting to export a react component as a PDF file. Here are the steps I have followed: Converting the component into an image using html2canvas Creating a PDF document Attaching the image to the PDF The component contains images with URLs ...