Expanding the text within an HTML document

As a newcomer to website development, I am working on my personal site and hoping to achieve smooth scrolling in the future. For now, my focus is on adding more text to the center of the screen. Despite trying various methods, I have not been able to achieve the desired result. My goal is to have a small line of text that reads "Hi, my name is", followed by a larger text displaying a name. Below this, I intend to include additional text in paragraph form. Here is an excerpt from my current code:

@import url('https://fonts.googleapis.com/css2?family=Karla:ital,wght@1,700;1,800&display=swap');
*

{
    margin: 0;
    padding: 0;
    bottom: 0;
    box-sizing: border-box;
    font-family:system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif;
}
body
{
    min-height: 100vh;
    background: linear-gradient(#000, #fff);
}
header
{
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    padding: 30px 50px;
    display: flex;
    justify-content: space-between;
    align-items: top;
}
header .logo
{
color: #fff;
font-weight: 700;
text-decoration: none;
font-size: 2em;
text-transform: uppercase;
letter-spacing: 1px;
}
.header img 
{
    float: left;
    width: 160px;
    height: 150px;
    position: absolute;
    left: 50px;
    top: -20px;

}
  

header ul
{
    display: flex;
    justify-content: center;
    align-items: top;
}
header ul li
{
    list-style: none;
    margin-left: 20px;
    margin-top: 10px;
}
header ul li a
{
    text-decoration: none;
    padding: 6px 15px;
    color: #fff;
    border-radius: 20px;
}
header ul li a:hover ,
header ul li a.active
{
    background: #CEE4F3;
    color: #000;
}
section
{
    position: relative;
    width: 100%;
    height: 100vh;
    padding: 100px;
    z-index: -1000;
    
}
section img
{
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    z-index: -1000;
    opacity: 1;
}
<!DOCTYPE html>
<html lang="en">
    <head>
        <title>personal site</title>
        <link rel="stylesheet" type="text/css" href="style.css">
</head>
<body>
    <header>
        <div class="header">
            <img src="logo-no-background.png" alt="logo" />
          </div>
        <ul>
            <li><a href="#" class="active">Home</a></li>
            <li><a href="#">About</a></li>
            <li><a href="#">Work</a></li>
            <li><a href="#">Personal Projects</a></li>
            <li><a href="#">Contact</a></li>
        </ul>
    </header>
    <section>
        <img src="7076118.jpg" id="wavy">
    </section>
</body>
</html>

Answer №1

If you want to gather user input, you can utilize the prompt() function in JavaScript. You can then take that input and assign it to the innerText of a specific element within the DOM.

const userInput = prompt('Please enter your email: ');
const emailElement = document.querySelector('.email');

emailElement.innerText = userInput;
<h2>Email Address:</h2>
<p class="email"></p>

Answer №2

Do you have a specific goal in mind? Feel free to experiment with the style properties to achieve the desired outcome. Remember to mark as correct if this was helpful 😉...

@import url('https://fonts.googleapis.com/css2?family=Karla:ital,wght@1,700;1,800&display=swap');
* {
    margin: 0;
    padding: 0;
    bottom: 0;
    box-sizing: border-box;
    font-family:system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif;
}

body {
    min-height: 100vh;
    background: linear-gradient(#000, #fff);
}

header {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    padding: 30px 50px;
    display: flex;
    justify-content: space-between;
    align-items: top;
}

header .logo {
color: #fff;
font-weight: 700;
text-decoration: none;
font-size: 2em;

letter-spacing: 1px;
}

.header img  {
    float: left;
    width: 160px;
    height: 150px;
    position: absolute;
    left: 50px;
    top: -20px;

}
  

header ul {
    display: flex;
    justify-content: center;
    align-items: top;
}

header ul li {
    list-style: none;
    margin-left: 20px;
    margin-top: 10px;
}

header ul li a {
    text-decoration: none;
    padding: 6px 15px;
    color: #fff;
    border-radius: 20px;
}

header ul li a:hover ,
header ul li a.active {
    background: #CEE4F3;
    color: #000;
}

section {
    position: relative;
    width: 100%;
    height: 100vh;
    padding: 100px;
    z-index: -1000;
    
}

section img {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    z-index: -1000;
    opacity: 1;
}

.intro {
  position: absolute;
  top: 50%;
  left: 50%;
  bottom: 40%;
  justify-content: center;
  align-items: center;
  transform: translate(-50%, -50%);
}

p {
  color: #fff;
}

.intro p:first-child {
  padding-bottom: 10px;
}

.intro p:last-child {
  font-size: 12px;
}

.intro span {
  font-weight: bold;
  font-size: 1.3rem;
}
<header>
  <div class="header">
      <img src="logo-no-background.png" alt="logo" />
    </div>
  <ul>
      <li><a href="#" class="active">Home</a></li>
      <li><a href="#">About</a></li>
      <li><a href="#">Work</a></li>
      <li><a href="#">Personal Projects</a></li>
      <li><a href="#">Contact</a></li>
  </ul>
</header>
<section>
  <img src="https://images.unsplash.com/photo-1478760329108-5c3ed9d495a0?ixlib=rb-1.2.1&ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&auto=format&fit=crop&w=1074&q=80" id="wavy">
</section>

<div class="intro">
  <p>
    Hi, my name is:
    <span>Name Surname</span>
  </p>
  <p>
    Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aenean nec lobortis nisi, eget faucibus neque. Morbi placerat sem at elementum aliquam. Aenean nec quam id elit ornare eleifend a et sapien.
  </p>
</div>

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

Utilizing the v-for directive to loop through JSON data with unique IDs and linking them to Input components in PrimeVue

In my database, I have a collection of products with a column named attributes that stores property/value pairs in JSON format. Each product can have unique attributes. For instance, one product's attributes could be: #product1 attributes { color: & ...

Using two divs, each containing different content, with one incorporating a tinymce editor, in order

There are two div elements in my code: <div id="ing" style="position:relative;"> <div id="comm" style="position: absolute; width: 27% !important; height: 141px; right: 18px; top: 1px; "> </div> </div> After that, I set T ...

Nested click jQuery with draggable elements

After taking advice from @amphetamachine in this thread, I was able to successfully manage nested clicks using jQuery. However, the drag feature that was previously functioning perfectly has now stopped working since I implemented the delegates. The main ...

Assistance needed for iterating through JSON data

I need assistance retrieving specific data from a JSON response in my JavaScript code. Unfortunately, the current approach is not providing the desired results: This is my JavaScript code snippet: function retrieveArtists(response){ var artistList ...

Confirm the drag-and-drop functionality for customers by utilizing the accept feature

Is it possible to customize my draggable & droppable module with these classes? stackDrop1 (Kitchen) stackDrop2 (Road) stackDrop3 (Completed) https://i.sstatic.net/vxFCx.jpg If the Customer George is in the Road class, the Kitchen class will not accept ...

Only one condition is met when using the Javascript if statement with the :checked and .bind methods

I need help creating an Override Button to disable auto-complete for a form using Javascript. I want the div "manualOverrideWarning" to display a warning if the button is selected, but my current function only works the first time the user presses the butt ...

"Troubleshooting: Sending null values through Jquery ajax to an MVC controller

The issue: I am facing a challenge with saving events in a calendar through ajax by sending the content to my controller function. Despite my efforts, I constantly see null values being passed to my database. Upon inspecting the Network tools console log ...

Triggering the jQuery `one()` event from multiple locations for the same element

On the second open of my modal, I am experiencing unexpected behavior where a .one() event is being triggered from a different location than expected. The first time I click on .modal-trigger, everything works fine. The same goes for clicking on .close-mo ...

Global installation of npm packages: Step-by-step guide

I've been interested in trying out Vue.js, but I'm struggling to figure out how to integrate it into my project. Is there a way to install the dependencies without requiring an internet connection to download them again, especially when they&apos ...

Is there a reason to not simply reset the connection to the $.ajax?

Ensure that the server is available before loading the scripts. On the client side jQuery(document).ready(function(){ jQuery.ajax({ dataType: "jsonp", timeout: 1000, cache: false, url: "http://xxx/include/xxx.php?q=? ...

python code to locate element using selenium

Currently, I am utilizing selenium in conjunction with Python to automate tasks. I am facing an issue where I have a checkbox element that I need to click on, but the only information I have about it is the text it contains. The text is located within a &l ...

Check the box to track the current status of each individual row

Recently, I encountered an issue with a form containing dynamic rows. Upon fetching records, my goal was to update the status of selected rows using checkboxes. Although I managed to retrieve checkbox values and dynamic row IDs successfully in the console ...

Is it possible to create a sticky element that stays fixed to the window without using JavaScript?

Using position: sticky has been a game-changer for me. It resolves many issues without the need for JavaScript. However, I've encountered a roadblock. I am trying to create a sticky element that is nested inside multiple <div> elements. Since po ...

Endlessly scrolling text using CSS

Is it possible to create a continuous rolling text effect on an HTML page without any gaps, similar to a ticker tape display? For example, displaying "Hello World ... Hello World ... Hello World ... Hello World ..." continuously. I attempted using the CSS ...

Creating a specialized .toString() function for an array

When trying to create a custom .toString() method on the Array prototype, how can you access the actual array that the method is called on? This approach seems to work: Array.prototype.toString = () => 'custom'; "" + [1,2,3]; // 'custom ...

Transitioning one element's opacity to zero while concurrently increasing another element's opacity to replace it

There are a total of 3 div elements and 3 links included in this setup. The goal is to only display one div at any given time. Upon clicking on a link corresponding to a different div, the current one should fade out while the selected one fades in seamle ...

JSON and autocomplete feature causing performance problems

Developing an application that functions both online and offline using technologies like application cache and local storage is my current project. Utilizing jQuery mobile along with a jqm autocomplete solution from , I aim to create a seamless user experi ...

Sending a parameter to the load method of the Selectize jQuery extension

I have a question about using the Selectize jQuery plugin for a dropdown box. I am not very familiar with jQuery, so please bear with me if this is a simple issue. I am making an ajax call to fetch data for the dropdown, but I need to pass a variable to th ...

JavaScript - Insert rows within the tbody element by adding them after the opening tbody tag. The new rows should be

Having trouble adding rows in JavaScript. The code is functioning correctly, but the new rows are appearing after the tbody tag instead of inside it. Here's a snippet of the code: function deleteRow(row) { var i = row.parentNode.parentNode.rowIn ...

Issue with nested tabs functionality within a pill tab panel in Bootstrap not functioning as expected

I'm facing a challenge with integrating tabs into a vertical pill tab panel in Bootstrap 4. Below is a brief code snippet: <html> <head> <link href="bootstrap.min.css" rel="stylesheet"> </head> <body> <script ...