How can I incorporate dynamic moving lines into my website's loading sequence?

Link to Gyazo image 1: https://gyazo.com/015425f0decb187e28b620c1e3206391 Issue with first image: https://gyazo.com/dfcd33e8a4fd5bea64e51fe40556f0bf

I'm currently working on a website and came up with a cool concept of having two lines crossing the screen upon loading. However, when I tried implementing this, every other element seemed to follow the trajectory of these lines. This made me suspect that there might be an issue in the code structure. So, my question is: How can I create two intersecting lines across the screen without having to resort to using 'position: absolute' for all other elements? I hope the provided code gives a clearer understanding of my problem.

I've experimented with various solutions but have yet to find the right one.

#horizontal-line {
  height: 0px;
  width: 2px;
  border-bottom: 1px solid #1e1e1e;
  -webkit-animation: increase 2s;
  -moz-animation: increase 2s;
  animation: increase 2s;
  animation-fill-mode: forwards;
  float: left;
}

@keyframes increase {
  100% {
    width: 100%;
  }
}

#vertical-line {
  height: 0px;
  width: 2px;
  border-left: 1px solid #1e1e1e;
  -webkit-animation: increaseV 2s;
  -moz-animation: increaseV 2s;
  animation: increaseV 2s;
  animation-fill-mode: forwards;
  float: right;
  margin-right: 25%;
  margin-top: -120px;
}

@keyframes increaseV {
  100% {
    height: 850px;
  }
}
<div id="horizontal-line"></div>
<div id="vertical-line"></div>

If anyone has a more efficient way to achieve the desired effect of crossing lines or spots any errors in the existing code, your insights would be highly valued!

Answer №1

Your code is facing an issue where the lines you've inserted are at the same "level"(z-index) as the rest of the page content. To resolve this, you can adjust the z-index of the lines to 1 and set their position to fixed. For the vertical line, make sure to include the property right: 0 to shift it to the right side;

#horizontal-line {
  height: 0px;
  width: 2px;
  border-bottom: 1px solid #1e1e1e;
  -webkit-animation: increase 2s;
  -moz-animation: increase 2s;
  animation: increase 2s;
  animation-fill-mode: forwards;
  float: left;
  position: fixed;
  z-index: 1;
}

@keyframes increase {
  100% {
    width: 100%;
  }
}

#vertical-line {
  height: 0px;
  width: 2px;
  border-left: 1px solid #1e1e1e;
  -webkit-animation: increaseV 2s;
  -moz-animation: increaseV 2s;
  animation: increaseV 2s;
  animation-fill-mode: forwards;
  position: fixed;
  float: right;
  margin-right: 25%;
  right: 0;
  z-index: 1;
  margin-top: -120px;
}

@keyframes increaseV {
  100% {
    height: 850px;
  }
}
<div id="horizontal-line"></div>
<div id="vertical-line"></div>
<img src="https://images.pexels.com/photos/414612/pexels-photo-414612.jpeg?auto=compress&cs=tinysrgb&dpr=2&h=650&w=940" width="200px"/>

Answer №2

After troubleshooting the issue, I came up with a solution:

#horizontal-line {
height: 0px;
width: 2px;
border-bottom: 1px solid #1e1e1e;
-webkit-animation: grow 2s;
-moz-animation: grow 2s;
animation: grow 2s;
animation-fill-mode: forwards;
float: left;
}

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

Error: Unable to assign value to property 'src' because it is null

Currently, I am attempting to display a .docx file preview using react-file-viewer <FileViewer fileType={'docx'} filePath={this.state.file} //the path of the url data is stored in this.state.file id="output-frame-id" ...

Comparing ASP MVC and PHP for uploading files: which is better?

This article on HTML5 file upload with a progress bar is really impressive: http://www.sitepoint.com/html5-javascript-file-upload-progress-bar/ However, the backend code provided is in PHP. I need assistance converting it to ASP.NET MVC3 or at least a go ...

There was an issue with the Google Maps embed API that resulted in an error with interpolation

My goal is to utilize the Google Maps API in order to showcase a map using data from a JSON file. However, whenever I attempt to incorporate the JSON data, an error message 'Error: [$interpolate:noconcat] Error while interpolating' pops up. < ...

Barba.jS is causing a delay in loading scripts after the page transition

One of my index files includes Gsap and Barba JS, while an inner page includes additional JS files such as locomotive.js and OWLcarousel.js. These two JS files are not necessary for the index page. However, when transitioning from the index page to the inn ...

Android not showing scroll bar in ion-scroll feature

I am experiencing an issue where a div with a fixed height displays a scroll bar on browsers but not on an Android phone. <ion-scroll style="height:300px;" scrollbar-y='true'> //content </ion-scroll> ...

What is the best way to center the 'email promo' text in the top navigation bar alongside the image and other text links?

Struggling with learning CSS and HTML, particularly when it comes to positioning elements on the page. I'm having trouble vertically aligning the elements inside the top nav bar and can't seem to figure out what I'm doing wrong. Any insights ...

Tips for successfully sending a nested function to an HTML button and dropdown menu

I'm working on two main functions - getChart() and fetchData(). The goal is to retrieve chart data and x/y axes information from a database. Within the getChart function, I'd like to incorporate a dropdown menu for displaying different types of c ...

An undefined PHP index error was encountered by Ajax, while the other one did not face the same issue

I encountered an issue with ajax where I am receiving an undefined index error on my variables when making a call. Strangely, I have other ajax calls functioning perfectly fine across my website except for this particular one which is giving me troubles. I ...

Is there a way to prevent the typing in a browser textbox from being affected by keyup events when sending a request?

On a website, there is a textbox that allows the user to input their text and receive results by changing the content through an AJAX request response. The issue arises when typing too quickly as the response may not keep up with the typing speed, resulti ...

Creating a modal form with jQuery in ASP.NET

I'm fairly new to ASP.NET development and have been able to work on simple tasks so far. However, I now have a more complex requirement that I'm struggling with. My goal is to create a modal form that pops up when a button is clicked in order to ...

Utilize Python (specifically with the Pillow library) to remove transparent backgrounds

When using the python module html2image to convert html to an image, I encountered an issue with fixed image size causing the html to break or get cut off, leaving a blank space. Is there a Python-based solution to fix this problem? (I am using chat export ...

The reflight response received an unexpected HTTP status code of 500

Recently, I've been working on utilizing the Yelp Fusion API by making a simple ajax call. I started off by using the client_id and client_secret provided by Yelp to successfully obtain an access token through a 'POST' request in Postman, fo ...

Creating dynamic height based on width using JavaScript

I'm trying to make a rectangle responsive based on the width of the window. This is my current logic: aspectRatio = 16 / 9 win = { width: window.innerWidth, height: window.innerHeight, } get browser() { const width = this.win.width - 250 ...

What is the best way to position a website in the center in the provided example?

Simple question here, couldn't find it in the search so sorry if it's a repeat. How is the content on this responsive website centered? I've checked the body margins but can't seem to locate anything. Thank you for your help. ...

Emphasis and dimension of form

I need help with a field that is supposed to have a black outline, similar to the one shown below: However, here is what I currently have in my code: .r{ height: 40px; font-size: 30px; width: 100px; font-family: 'proxima_novalight ...

Elements styled as inline blocks with static dimensions, irregular in size

Is there a way to ensure that all three boxes are displayed at the same level? Currently, box 2 appears below box 1 and 3 due to having less content. I believe there must be some styling element missing to make each div display at an equal level regardless ...

Is the z-index useless when the button is positioned behind divs and other elements?

I would like the "Kontakt" button to appear in the top right corner of the page, always on top of everything else. I have tried setting the z-index to z-index: 99999999999 !important;, but it doesn't seem to be working... On desktop, the button displ ...

The jQuery toggle function is malfunctioning when applied to the rows of a table

I have been experimenting with toggling table rows using jquery. Initially, the state is hidden This feature is functioning properly $('.table tr.items.' + name).each(function() { $(this).show(); }); Furthermore, this snippet of code is wor ...

Combining a Python backend with an HTML/CSS/JS user interface for desktop applications: the perfect synergy?

Is it possible to seamlessly combine Python code with HTML/CSS/JS to develop desktop applications? For instance, I want to create a function in Python that displays "Hello World!" and design a visually appealing user interface using HTML/CSS/JS. How can I ...

Refresh table in php without the need to reload the entire page

Currently, I am retrieving data in a table from the database and have three buttons - update, delete, and an active/inactive button. Each button has its own functionality, but I need to reload the updated data in the table after any event without refreshin ...