No matter how much I try, the text refuses to align with the top-left corner

I have been working on creating a loading screen, but I am facing an issue with aligning the h1 tag selected to the top left. As a young developer at the age of 13, I am quite confused. I attempted to use the following CSS properties:

vertical-align: top;
text-align: left;

However, it did not yield the desired result. Any assistance provided would be greatly appreciated.

Here is the code snippet:

HTML5:

<!DOCTYPE html>
<!-- More HTML code here -->
</html>

CSS3:

::selection {
  color: #ffff;
  background: rgb(142, 73, 232);
}

/* More CSS styles here */

Answer №1

The request was to align the text in the upper left corner, but what about the animation? I assumed it should be centered.

To address this, I utilized absolute positioning for the h1 text in my solution.

Here is how you can achieve this:

Include these properties - position: absolute, top: 0, left: 0, and margin: 30px within your .text-logo selector as shown below:

.text-logo {
  position: absolute;
  top: 0;
  left: 0;
  margin: 30px;     
  color: rgb(142, 73, 232);
}

::selection {
  color: #ffff;
  background: rgb(142, 73, 232);
}
html, body {
  height: 100%;
  margin: 0;
}
*{
  box-sizing: border-box;
}
body {
  text-align: center;
  display: -ms-flexbox;
  display: flex;
  -ms-flex-pack: center;
  justify-content: center;
  -ms-flex-align: center;
  align-items: center;
  background: linear-gradient(to bottom, rgb(38, 76, 158) 0%, rgb(42, 143, 119) 100%);
}
svg {
  width: 120px;
  height: auto;
}
.text-logo {
  position: absolute;
  top: 0;
  left: 0;
  margin: 30px;      
  color: rgb(142, 73, 232);
}
<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>SideQuests | Simple but Powerful Todo App</title>
  <!--meta http-equiv="refresh" content="2;url=home" /-->
  <link rel="stylesheet" href="loader.css">
  <link rel="icon" href="images/sidequests-logo.png">
  <meta property="og:image" content="images/sidequests-logo.png">
  <meta property="og:title" content="SideQuests | Simple but Powerful Todo App">
  <meta property="og:description" content="SideQuests is a simple but powerful todo app that can list any task you want, and it also saves the tasks into the LocalStorage. Meaning, even if you refresh or leave the website, it will still save your progress.">
  <meta property="og:url" content="https://www.sidequests.ga">
</head>
<body>
  <h1 class="text-logo"><i class="fas fa-check-square"></i> SideQuests</h1>
  <svg version="1.1"
  xmlns="http://www.w3.org/2000/svg"
  xmlns:xlink="http://www.w3.org/1999/xlink" viewBox="25 25 50 50">
  <circle cx="50" cy="50" r="20" fill="none" stroke-width="5" stroke="#45d6b5" stroke-linecap="round" stroke-dashoffset="0" stroke-dasharray="100, 200">
    <animateTransform attributeName="transform" attributeType="XML" type="rotate" from="0 50 50" to="360 50 50" dur="2.5s" repeatCount="indefinite"/>
    <animate attributeName="stroke-dashoffset" values="0;-30;-124" dur="1.25s" repeatCount="indefinite"/>
    <animate attributeName="stroke-dasharray" values="0,200;110,200;110,200" dur="1.25s" repeatCount="indefinite"/>
  </circle>
</svg>
</body>
</html>

Answer №2

Just a friendly reminder - please refrain from adding any elaborate styling directly to the body tag. It's best to encapsulate your content within div tags. Additionally, using display:flex can be quite complex, so it's important to have a good grasp of its functionality before implementing it.

Feel free to take a look at this fiddle I've put together as a solution for your specific requirements: http://jsfiddle.net/boa3xh17/

Answer №3

Take a look at the code below and see if it suits your needs.

::selection{
  color: #ffff;
  background: rgb(142, 73, 232);
}

html, body{
  height: 100%;
  margin: 0;
}
*{
  box-sizing: border-box;
}
body{
  background: linear-gradient(to bottom, rgb(38, 76, 158) 0%, rgb(42, 143, 119) 100%);
}

svg{
  width: 120px;
  height: auto;
}
.loader{
  text-align: center;
  display: flex;
  align-items: center;
  justify-content: center;
}
.text-logo {
  color: rgb(142, 73, 232);
      margin: 0;
}
  <h1 class="text-logo"><i class="fas fa-check-square"></i> SideQuests</h1>
  <div class="loader">
  <svg version="1.1"
  xmlns="http://www.w3.org/2000/svg"
  xmlns:xlink="http://www.w3.org/1999/xlink" viewBox="25 25 50 50">
  <circle cx="50" cy="50" r="20" fill="none" stroke-width="5" stroke="#45d6b5" stroke-linecap="round" stroke-dashoffset="0" stroke-dasharray="100, 200">
    <animateTransform attributeName="transform" attributeType="XML" type="rotate" from="0 50 50" to="360 50 50" dur="2.5s" repeatCount="indefinite"/>
    <animate attributeName="stroke-dashoffset" values="0;-30;-124" dur="1.25s" repeatCount="indefinite"/>
    <animate attributeName="stroke-dasharray" values="0,200;110,200;110,200" dur="1.25s" repeatCount="indefinite"/>
  </circle>
    </svg></div>

Avoid using the body style that you have implemented in this code snippet.

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

Conceal the div element if the screen size drops below a certain threshold

Is it possible to hide a div element when the browser width is less than or equal to 1026px using CSS, like this: @media only screen and (min-width: 1140px) {}? If not, what are some alternative solutions? Additional information: When hiding the div eleme ...

Scrolling to a specific position on a page when a Vue 3 component appears is a must-do for

When I click a button, my basic form component appears without using the router. I would like the scroll position of the form to automatically move down slightly (for example, on the y-axis at 40) once it is displayed. However, I am unsure of how to achi ...

Disappearance of external page upon refreshing - jquery mobile

I'm in the process of developing a jQuery mobile application that loads external pages into a specified div when a link is clicked. These externally loaded pages contain links to additional pages. However, I've noticed that when I click on these ...

Windowing box inside a container box

I am looking to implement scrolling for just the "chat-messages" div within the "chat-bar" div on my site. I want only this specific section to be scrollable, while the rest of the site remains stationary. Currently, I have to scroll through the entire pag ...

Arranging content within columns according to their column position

As I design a grid with three columns, each grid box contains a div with a maximum width of 280px. Sometimes the grid columns exceed this width. To achieve my desired layout, I aim to align the content in the grid boxes so that the left column aligns to th ...

Ensure that a distinct cross button is included within the text or search input and positioned to float alongside the text for

Is there a simple method to include a clear button that hovers after the text in an input field when using a search type input? <input type="search"> ...

JavaScript - Declaring canvas as a global object

Presently, I am experimenting with HTML5 and using JavaScript to create a basic 2D Tile map. Progress is going smoothly; however, I have come across an issue where I am unable to contain everything within one large function. I am attempting to make the ca ...

Employing Bootstrap, incorporate a vertical divider in the center to split three icons on the left and three icons on the right, all while ensuring the design remains responsive

I have been struggling with a layout issue for the past couple of days and I am in need of assistance from someone who can help me. Unfortunately, I am unable to upload an image here as I am new and do not yet have enough reputation points. The Layout Str ...

Filter search results to display only posts

My website uses a custom Wordpress theme that has a search functionality. The issue I'm facing is that when I perform a search, it redirects me to the search.php page. However, instead of just displaying posts, it also shows pages and events from the ...

Using jQuery to insert a new string into the .css file

I'm currently working on a jQuery function to make my font size responsive to changes in width. While I am aware of other options like Media Query, I prefer a solution that offers smoother transitions. Using vw or vh units is not the approach I want t ...

Modifying HTML elements with JavaScript - a practical guide

I'm trying to dynamically add the variable x to an existing HTML tag. The goal is to update the image tag <img id="Img" src="IMG/.jpg"/> by appending the variable x at the end of its id and source: <script> var images ...

The accuracy of real-time visitor numbers in Google Analytics is often unreliable

My website uses Google Analytics to track the page chat.php. The code snippet is correctly placed on the page according to the documentation. Within this page, there is a Flash object that connects users to an IRC chat room. Currently, there are 50 unique ...

Is it possible to modify the value on the src img tag prior to scraping the data

Hey everyone, check out this piece of code I have: foreach ($image as $snimka){ $url = $snimka->src; $ch = curl_init($snimka->src); $fp = fopen('images/' . basename($url), 'wb'); curl_setopt($ch, CURLOPT_FILE, $fp ...

A guide on switching out an HTML element with an AJAX response

How can I dynamically replace an HTML element with Ajax response? I know how to remove the element, but I'm unsure how to then insert the new content from the Ajax call. For instance, let's say I have the following code: <ul id="products"> ...

Establishing Fixed Positioning

I'm currently working on fixing the position of an image at the top of a mobile view page. .fixed { position: fixed; } This is specifically for use with Ionic. <div class="item item-image polygon"> <img src="http://urbanetradio ...

Changing the identification of elements

I noticed that when I open object X and Y, they have the same fields, tabs, and checkboxes. However, I am confused as to why the IDs of the checkboxes and other elements are different. Can you explain what gwt-uid(number) means? Please take a look at the a ...

Issues with CSS3 height transitions in a specific scenario

Check out this simplified version of my code on CodePen: http://codepen.io/anon/pen/pjZXob I am attempting to create a smooth transition in the height of the .destinationsTopicContent div, from 0 to auto. However, it is nested within a div that has visibi ...

Organize group data by month in a visually appealing table using HTML/PHP with

I have successfully implemented a code that prints HTML table rows from a database table and sorts them by date. The challenge lies in the fact that the date is stored as VARCHAR (due to a pre-existing project with an active database used in a PHP web app ...

What is stopping me from utilizing ES6 template literals with the .css() method in my code?

I am currently working on a project where I need to dynamically create grid blocks and change the color of each block. I have been using jQuery and ES6 for this task, but I am facing an issue with dynamically changing the colors. Below is the snippet of m ...

:hover doesn't fully implement background color on list items

When I hover over the dropdown items in my navigation menu, I would like the background color to change for the entire list item. Currently, the background color only changes when hovering over the text itself and reverts back to its original color when mo ...