Abstract forms on the canvas are dancing in a strange and unusual rhythm

As a beginner in web design, I've made progress but still have questions. Can someone help explain this to me?

Here is how a specific section on my website is set up: https://i.sstatic.net/8ntpR.png

I'm working on splitting the screen with 40% image and 60% text. Everything seems fine, but why is the text showing up at the bottom instead of the top? Did I make a simple mistake?

Below is my HTML code:

<section>
<div class="about">
  <div class="about_img"></div>
    <div class="about_text">
      <h1>Some Text</h1>
      <p>Some supporting text</p>
</div>
</section>

And here is the CSS for the section:

.about{
    width: 100%;
    height: 300px;
    background-color: #F0F0F0;
    min-height: auto;
    display: inline-block;
}
.about_img{
    width: 40%;
    height: 100%;
    background-image: url("/assets/alex-image.JPG");
    background-size: cover;
    display: inline-block;
 }
 .about_text{
     width: 20%;
     display:inline-block;
     position: relative;
     margin-left: 50px;
 }

If you need more information, please ask. You can also view my site at

Thank you,

Answer №1

Response, special thanks to CBroe.

To position the element at the top of the block, apply vertical-align: top;

Answer №2

For aligning the <div class="about_text"> vertically on top, you can include vertical-align: top in the CSS style.

Possible options

Additional values can be found on this website:

vertical-align: middle

This places the element in the center of the parent element

vertical-align: bottom

Aligns the bottom of the element with the lowest element on the line

vertical-align: {length}

Changes the element's position by a specified length. Negative values are accepted

vertical-align: {X}%

Adjusts the element's position by a percentage of the "line-height" property. Negative values are accepted

vertical-align: sub

Positions the element as if it were subscript

vertical-align: super

Positions the element as if it were superscript

vertical-align: text-top

Aligns the top of the element with the parent element's font top

vertical-align: text-bottom

Aligns the bottom of the element with the parent element's font bottom

Default setting

The default value is:

vertical-align: baseline

Aligns the element's baseline with the parent element's baseline

Answer

.about{
  width: 100%;
  height: 300px;
  background-color: #F0F0F0;
  min-height: auto;
  display: inline-block;
}
.about_img{
  width: 40%;
  height: 100%;
  background-image: url("http://www.alexwiley.co.uk/assets/alex-image.JPG");
  background-size: cover;
  display: inline-block;
}
.about_text{
  width: 20%;
  display:inline-block;
  vertical-align: top;
  position: relative;
  margin-left: 50px;
}
<div class="about">
  <div class="about_img"></div>
  <div class="about_text">
    <h1>Some Text</h1>
    <p>Some supporting text</p>
  </div>
</div>

Answer №3

To position the text at the top, include the following CSS code :

align-items: start

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

Can I inspect the HTML source of GWT?

How can I access the HTML source code generated by GWT? Currently, I only see the DIV with a specific ID when viewing the source. Is there a way to view the entire HTML output? Is it possible to design my table in HTML using divs and lists, then wrap it i ...

Tips for creating a star program using Angular 2+

Create an Angular 2+ code snippet that will print asterisks (*) in a list on button click. When the button is clicked, it should add one more asterisk to the list each time. For example: Button Click 1 - Output: * Button Click 2 - Output: ** Button Cl ...

Identifying browser compatibility for date input type with Angular 2 and above

Is there a reliable method to check if the browser supports <input type="date"> in Angular2+? I came across a suggestion on https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/date where they recommend creating the input element and chec ...

Angular displaying a slice of the data array

After following the example mentioned here, and successfully receiving API data, I am facing an issue where only one field from the data array is displayed in the TypeScript component's HTML element. Below is the content of todo.component.ts file im ...

What's the best way to align several buttons in the center of the screen horizontally?

I'm struggling to properly align divs with images inside another div. My goal is to insert buttons into my HTML and use jQuery to center them automatically, but I can't seem to get it right. You can view the fiddle I've created here: http:/ ...

In order for Angular forms to be considered valid, they must fall into one of two form

I am attempting to create a dynamic angular form where the user must enter either A or B. A represents a unique identifier, while B consists of a set of values that correspond to that identifier. My goal is to validate the form as valid if either A is ente ...

HTML/CSS Inactive: Troubleshooting and Solutions

There seems to be an issue with the :active state, if anyone can spot the problem and provide assistance, it would be greatly appreciated. Here is the HTML code: http://pastebin.com/4wCi3L2Z And here is the CSS code: http://pastebin.com/jZvgdDaA Thank y ...

What is the best way to apply CSS styles to a child div element in Next.js?

I'm currently working on enhancing the menu bar for a website project. Utilizing nextjs for my application I am aiming to customize the look of the anchor tag, however, encountering some issues with it not rendering correctly. Here is a snippet of ...

Is there anyone who can provide a comprehensive explanation for what is going on here?

{ // Let's figure out how to launch my HTML file as a webpage in Chrome. "version": "0.2.0", "configurations": [ { "type": "pwa-chrome", &q ...

Arrange three input fields horizontally with labels positioned above each

I am facing a minor problem with aligning three input fields in the same row while maintaining equal spacing between each of them. I attempted to accomplish this using display: flex and space-between, but then the label appears to the left of the input in ...

Using JavaScript import may encounter issues when trying to access the same file or a different file

When importing something and using it, there are certain scenarios where it may not work as expected. For example: <html> <body> <button onclick="foo()">Click Me</button> </body> <script type="module"> ...

Highlighting the selected tab with an active class

Currently in the process of learning angularJs, I am still new to it and attempting to dynamically add an active class to the recently clicked tab. Within my interface, there are four tabs: insert, view, update & delete. My goal is to apply the active ...

Deactivate additional fields when choosing an option from the drop-down selection menu

When designing a form with a select dropdown that displays various options, I encountered an issue. I want to disable certain fields if a specific option is chosen from the dropdown. For instance, if "Within Company" is selected in the transaction type, I ...

Top tips for seamless image transitions

Currently working on a slideshow project and aiming to incorporate smooth subpixel image transitions that involve sliding and resizing, similar to the Ken Burns effect. After researching various techniques used by others, I am curious to learn which ones ...

"Is there a way to transfer a value from one list box to another without needing to refresh the page, by utilizing AJAX,

Is there a way to automatically load Related Course levels in the Course Level Listbox when selecting a Course from the Course list? <script type="text/javascript" src="js/jquery.js"></script> <div>Course:<select name="course_id" id= ...

Integrating node.js into my HTML page

Forgive me for sounding like a newbie, but is there a simple way to integrate node.js into my HTML or perhaps include a Google API library? For example: <script>google.load(xxxx)</script> **or** <script src="xxxx"></script> ...

Enhancing Your Vue Experience: A Guide to Highlighting and Selecting HTML Elements on Mouse Hover

Incorporating a navigation header using Vue, I utilize v-html to display it seamlessly. Check out the demo - here <section class="text-gray-700 font-heading font-medium relative bg-gray-50 bg-opacity-50"> <nav class="flex justify ...

Different Ways to Make Custom Checkboxes Overlap with Labels in CSS

Hello everyone, I am currently diving into the world of CSS and HTML. My goal right now is to create a custom checkbox with a list of options. During my research, I stumbled upon an example on how to create custom checkboxes at this link. However, when imp ...

Tips for organizing dynamic table data following an append operation

Hey there! I'm currently working on a project involving sorting students after applying filters. Once the students have been filtered, I need to append classes and text to buttons as shown in the image below: https://i.stack.imgur.com/c9Mtm.png The HT ...

Guide to displaying highcharts using external json data for numerous series

Having an issue with using angularjs and highcharts with multiple series where the data is coming from an external JSON file. When trying to access the data with a for loop using data.data[i].data, it's not working properly. Can anyone offer assistanc ...