Repositioning an item to the top of the container using flexbox

I'm having trouble moving the "About me" header to the top of the section as it's currently positioned in the middle.

Another issue I'm facing is that my second paragraph is displaying on the same line as my first paragraph.

It's interesting to note that if I remove the "about" id, the layout fixes itself perfectly. However, I want to use flexbox and learn how to implement it properly, so I'd prefer not to take that shortcut unless absolutely necessary.

#about {
  margin-top: 50px;
  margin-left: 30px;
  display: flex;
  flex-flow: row;
}
.aboutme {
  font-family: 'Indie Flower', cursive;
  padding-top: 25px;
  order: 1;
  font-size: 2em;
}
.profile-photo {
  position: relative;
  top: 120px;
  left: 20px;
  order: 0;
  max-width: 700px;
  max-height: 500px;
  border-radius: 50px;
}
p {
  order: 2;
  position: relative;
  top: 50px;
  left: 50px;
  font-size: 1.25em;
  font-family: "Lucida Sans Unicode", "Lucida Grande", sans-serif;
  color: #000
}
<div>
  <section id="about">
    <img src="img/meprofile.jpg" alt="Photograph of" class="profile-photo">
    <h2 class="aboutme">About me</h2>
    <p>Hello!.</p>
    <p>Check</p>
  </section>
</div>

Answer №1

To achieve a different layout, switch the flex-direction: row property to column.

By changing to column mode, the elements will stack vertically similar to a standard block layout, causing your design to appear "fixed" when removing the #about CSS rules.

Once the change is made, both display: flex and flex-flow: row properties become inactive, resulting in the elements stacking in a vertical manner as per the standard block layout.

#about {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}
.aboutme {
  font-family: 'Indie Flower', cursive;
  font-size: 2em;
  text-align: center;
}
.profile-photo {
  height: 50%;
  width: 50vw;
  border-radius: 50px;
  margin: 0 10px;
}
#about > div {
  display: flex;
  margin: 0 10px;
}
p {
  font-size: 2vw;
  font-family: "Lucida Sans Unicode", "Lucida Grande", sans-serif;
  color: #000
}
body {
  background-color: white;
}
<section id="about">
  <h2 class="aboutme">About me</h2>
  <div>
    <img src="http://i.imgur.com/JV8yEjp.png" alt="Photograph of" class="profile-photo">
    <div>
      <p>Tart donut marzipan croissant sugar plum gummi bears apple pie. Wafer chocolate cake chupa chups macaroon danish topping. Bear claw gingerbread caramels chocolate bar chocolate marshmallow tart. Liquorice powder dessert.</p>
      <p>Wafer lemon drops tootsie roll halvah powder chupa chups apple pie. Sweet roll chocolate bar fruitcake chocolate biscuit gummi bears.</p>
    </div>
  </div>
</section>

Customize Your Layout on jsFiddle

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

Issues arising from utilizing Twitter Bootstrap 3.1.x, the box-sizing property, and Revolution Slider

I'm currently working on a PyroCMS theme that is built with Twitter Bootstrap 3.1.x and includes Revolution Slider. However, I've encountered an issue where the property box-sizing: border-box; creates an unwanted grey border as shown in the imag ...

Get an item from within a collection of objects

I'm in the process of creating a board game, and I am looking to implement a feature where clicking on a specific location will turn it red. I have an array of divs, but I'm struggling to figure out how to target and change the color of a specifi ...

Changing the default view in Ionic

I'm facing a simple issue that I can't seem to solve. I've set up a blank project in Ionic and I want to make a default home screen the first view that loads. However, all I see is a blank screen when I run it in the browser. Here's my ...

Enhancing Fullpage.js with a custom scroll delay feature

One issue I'm having is with a fading div "box" using ".fp-viewing" as a trigger for the transition effect. The problem arises when the page begins scrolling upon .fp-viewing being activated, causing the box to scroll out of view before its animation ...

I need assistance comprehending the terms "constructed stylesheet" and #shadow-root in CSS

I am currently trying to override some CSS for an Angular widget, but no matter what I try, the styles don't seem to change. It appears that the widget is being loaded into multiple nodes labeled #shadow-root. I have done some research on this issue, ...

Incorporating a CSS drop-down menu that appears or changes upon clicking

I am in the midst of designing a webpage with a main div that is 1000px by 1000px. Within this main div, there is a horizontal bar located at the top, divided into four sections - each occupying 1/4 of the space. In the center of each section, there is tex ...

Turn off sticky sidebar feature for mobile-friendly layout

I have encountered an issue with my script that I need assistance with. I am trying to disable this script for responsive or mobile view, but despite trying various methods, it is not functioning as expected. <script type="text/javascript"> $(func ...

Sort items based on the value of the chosen option

The snippet of code provided appears to be functioning properly, but there is an issue with error correction. If a mistake is made in the order, the entire text gets erased and restarts from scratch: function getValues() { var result = []; var me = this; ...

Learn the process of updating a specific section of a Facebook share link using AJAX dynamically

Here's an interesting scenario I'm dealing with. I'm trying to create a modification to the Facebook share button link where a portion of the link is replaced by a user ID number. This way, when someone clicks on the shared link, it will dir ...

When scrolling, the menu is being overlapped by the Carousel in HTML5, CSS3, and

I am currently working on a One Page HTML webpage that needs to be responsive, and the requirement is to use Bootstrap. I have gone through all the tags but can't seem to identify the issue. One problem I encountered is that when I scroll down the pa ...

Tips for integrating jQuery styling into Angular 2

Using the farbtastic color picker, I am trying to pass the color code from jQuery to the HTML element with the property [style.backgroundColor]="color" when a button is clicked. HTML: <button ion-col full clear id="color-picker-handler" (click)="initi ...

The Wordpress resource was recognized as a stylesheet, but was transmitted with the mime type text/html

After making a minor adjustment in my functions.php file, I've encountered an issue where some stylesheets are not loading properly. Additionally, whenever I visit my web page, the following error message appears in the console: "resource interpreted ...

Different placeholder text rendered in two text styles

Can an input box placeholder have two different styles? Here's the design I have in mind: https://i.stack.imgur.com/7OH9A.png ...

"Implementing Line Breaks in ASP.NET Core: A Step-by-Step

Is there a way to show HTML text with line breaks preserved? public void OnGet() { ViewData["Msg"] = "Hello World \n Hello World \n Hello World \n Hello World"; } The text above has embedded line feeds. @page @model ...

Create a feature that allows users to easily copy text with

Looking to utilize this Bootstrap code for generating an address and adding copy button functionality: <div class="modal fade" id="bitcoinModal" role="dialog"> <div class="modal-dialog modal-lg"> <d ...

Techniques for transferring images directly into HTML canvas games

I created a thrilling race car game and here is the code snippet: index.html <!DOCTYPE html> <html> <head> <title> Extreme Race Car Game </title> <link rel="stylesheet" type="text/css" href="style.css"> < ...

What steps can I take to stop the background image from zooming in modal view?

I noticed something strange happening when I open a modal after clicking on an image on my website. The background image seems to zoom in along with the modal, thanks to a new class called .modal-open added to the body element. This class includes addition ...

Look into HTML and JavaScript problems specific to IOS devices

I have encountered some HTML markup and JavaScript functionality issues on my web-app that seem to only occur on iPad and iPhone. Unfortunately, I do not have access to any iOS devices to debug these problems. How can I replicate and troubleshoot these i ...

Fiddle demonstrates HTML functionality, while local testing is unsuccessful

Currently, I am in the process of creating an image slider and attempting to run it on my personal computer. However, upon doing so, I have encountered a problem where the page is not rendering correctly. Additionally, I receive an ActiveX warning message ...

Is it possible to build an AngularJS application without utilizing HTML5?

Having created an AngularJS application, I have noticed that it functions smoothly on modern browsers. However, some of my devices run on old browsers that do not support html5. Unfortunately, I am unable to upgrade these browsers. Is there a method to ope ...