I'm currently working on developing a CPS tester, but have encountered a few challenges along the way

All of the text remains aligned to the left, despite my attempts to position it at the top.

I feel like I haven't even completed 1% of the task and I'm faced with countless issues.

Although I've coded it so that every click should increment by 1, it's still stuck at 0 every time you click.

This is the code snippet:

<title>CPS Tester</title>

<script type="text/javascript">
    let clicks = int(0)
    elem = document.getElementById("numClicks").innerHTML
        = var clicks
</script>

<style>

    @font-face{
        font-family: font;
        src:url('assets/font.ttf')  format('truetype')
    }

    div.clickhere{
        text-align: left;
        position: top;
        z-index: 0;
    }

    div.stats {
        text-align: right;
        font-family: "font";
        position: top;
        z-index: 1;
        background-position-y: 0;
    }
</style>
<div class="clickhere">
    <img src="assets/button1.png" onclick="click();">
</div>

<div class="stats">
    <button onclick="start()">Start</button>
    <p>You have clicked <span id=numClicks>0</span> times.</p>
</div>

<script type="text/javascript">

    var click = int(0); 
    clickhere.onclick=click(){click ++;}
    
    function start {
        let clicks = int(0)
        document.getElementById("numClicks").innerHTML 
            = var clicks
    }

    function click() {
        var clicks = var clicks + int(1)
        document.getElementById("numClicks").innerHTML
            = var clicks
    }

    function calculatecps(inclicks, seconds) {
        var cps = inclicks / seconds
        return cps
    }   

</script>

This CSS issue has me frustrated, as it's set to top but appears at the bottom

Answer №1

position: top is not a recognized CSS attribute.

For the desired effect, consider using the following code instead:

position: absolute; top: 10px; right: 10px

This will position the element in the top right corner of the page. (https://developer.mozilla.org/en-US/docs/Web/CSS/position).

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

Having trouble uploading several files with Multer functionality?

I've encountered an issue with Multer in Node.js where I can't seem to select and upload multiple files. In a previous exercise, I had no trouble uploading a single file, but now I'm struggling with enabling multiple uploads. What am I mis ...

Having trouble configuring Angular-UI Router to work properly with Apache server

My web app is running on my PC through an Apache server, but I'm having issues with the routing provided by ui.route. It seems that the simple state I defined is never being reached. To troubleshoot, I added a wildcard to catch all paths and found th ...

The issue I am facing is that the map function is not functioning correctly when I click

I am currently working on a project in ReactJs that includes a sidebar with dropdown menu functionality. Desired Outcome When I click on an option in the sidebar that has a submenu, it should display that submenu and close upon another click. Curr ...

Unexpected behavior occurs when ajax is added to an array for jQuery promise results

In my code, I have an each loop that makes individual AJAX requests and stores them in an array like this: var promises = []; $items.each(function(k, v) { promises.push( $.ajax({ url: ..., .... }) ); }); $.when.app ...

Leveraging AJAX within a RESTful API in a Node.js environment to retrieve a JSON file and dynamically parse its contents according to the specific button selected on the front-end interface

Can anyone help me with understanding the communication process between server.js (Node.js) and the front-end JavaScript file? I am trying to implement AJAX as a RESTful API in the server to retrieve a JSON file, parse it based on specific button clicks in ...

loop through array and assign values to elements

Is it possible to assign the values of a, b, c to each li? Right now, with my current code, I am only able to get all c. arr = ['a','b','c']; arr.forEach(function(obj){ var x = obj; $('li').each(function () { ...

Retrieve the file path of an uploaded image in a Razor view using jQuery Ajax

I have been facing challenges while working on an ASP.NET MVC3 application where I am developing a custom image gallery. The browser being targeted is IE9, which rules out the option of using HTML5 File API. All my code resides within a strongly typed Razo ...

Troubles arise when compiling TypeScript to JavaScript

I have been experimenting with TypeScript, specifically for working with classes. However, I am facing an issue after compiling my TS file into JS. Below is the TypeScript code for my class (PartenaireTSModel.ts): export namespace Partenaires { export ...

Locating the nearest image within a specific div using jQuery's find method

Here is the HTML I used on my page: <div class="edge-img-sec"> <img src="img1" alt="edge-icon" class="edge-icon1"> <img src="img2" alt="right-icon" class="edge-icon1-right"> </div> <div class="edge-img-sec"> < ...

Creating a Mongoose schema to store an array of objects, where updates will automatically add new objects

const mongoose = require('mongoose'); module.exports = mongoose.model('GridModel', { Request_Id : { type : Number, required : true }, viewStudents : { type : Array , default : [] } }); The mongoose model above needs to b ...

Guide on moving elements to a different list with the help of the Angular DragDrop CDK Service

I encountered a unique situation while working on my project where I needed to implement a drag and drop feature for multiple lists using Angular CDK's DragDrop service. While I was able to successfully move items within a single list, transferring an ...

Loading components dynamically with axios is a valuable feature

Can this be achieved? There is a spinner component. axios: action() { SPINNER (component) -- activate axios.get('/store', { params: { something } }) .then ((resp) => { SPINNER (component) -- ...

Using PHP to display dynamic data and add it to an HTML element

I have a unique situation where I am storing html elements, specifically <rect> svg elements, as strings in a database. In my PHP code, I retrieve and echo this data: $db = getConnection(); $statement = $db->prepare('SELECT `copy` FROM `dra ...

What are the steps to add a background image in Chrome?

Is there a way to set a background image using CSS and HTML that is compatible with Chrome? The code below works in Internet Explorer, but not chrome. Any suggestions? body { background-repeat: no-repeat; background-color: transparent; back ...

Could we confirm if this straightforward string is considered valid JSON data?

There are numerous intricate questions on Stack Overflow about whether a complex structure is considered valid JSON. However, what about something much simpler? "12345" Would the provided code snippet be considered valid JSON? ...

Utilizing the $http.post method in AngularJS together with PHP

I'm encountering issues while attempting to send the message, name, and email from a contact form on my index page to my own email using AngularJS. Upon clicking submit on the form, it only displays a loading screen without any further action. This is ...

Blending components from two arrays in a designated sequence

Currently, I am dealing with 2 arrays selectedERO[] = {"Device A, Device B, Device C"} selectedLinks[] = { "Port A1 - Port B1, Port B2 - Port C1" ) I am looking to create a pathway from device A to device C, and I want it to be presented in an array for ...

sending a file using ajax and handling it with php

Curious if there's a way to upload a binary file through ajax and php, without having to refresh the entire page like with a traditional html form. I've been able to gather input from radio buttons and text boxes using forms and javascript, but w ...

Adjust the size and position of the text input field

I'm struggling to find a way to both resize and move the box without one action interfering with the other. Whenever I attempt to change the size of the box, it triggers the move event at the same time. Clicking on the box should make it resizable, bu ...

The function `map` cannot be applied to `this.state.[object]`

It seems like I might be overlooking a simple mistake, but I keep encountering this.state.iata.map is not a function , even though I have bound the context to all functions where I need to access that state. Additionally, the iata state is an array, s ...