Issue with specialized HTML block on WordPress

I've been working on a website and I added a custom HTML block with HTML, CSS, and JavaScript. However, when viewing the page, it seems to be hidden behind other content for some reason.

Here's where the custom HTML is located
This is how the custom HTML block looks inside Wordpress

body {
  background-color: #eee; 
}
#canvas1{
  background-color: #fff;
  border: 1px solid #ccc;
}
.slider {
  width: 400px;
  color: #ccc;
}
.wrapper {
  position:relative;
}
.wrapper > canvas,
.wrapper > input {
  position:absolute;
  left:50px;
  top:50px;
}
.wrapper > input {
  left:150px !important;    /* places the slider */
  top:450px;
}
<div class="wrapper">
  <canvas id='canvas1' style="margin:0 auto;display:block;" width="600" height="500"><p>Your browser does not support html5 canvas.</p></canvas>
  <input id="volume" class="slider" type=range min=0 max=199 value=0 oninput='realTime(this)'>
</div>
//in this particular example, canvas1 represents an 800x800 canvas element
var context = document.getElementById('canvas1').getContext('2d');

context.font = '16px Roboto, "Helvetica Neue", Helvetica, Arial, sans-serif';
context.fillStyle = "#4D5C6D";
// a + b = width
var width = 200;
var focal = 0;
var timer = setInterval(function() {
  drawEllipse(300, 250)
}, 100);

function realTime(obj) {
  clearInterval(timer);
  focal = obj.value;
  drawEllipse(300, 250);
  context.fillStyle = "#BBB";
  context.fillRect(18, 145, 160, 20);
  context.fillStyle = "#FFF";
  context.fillText("Click to restart", 25, 160);
  context.fillStyle = "#4D5C6D";
}

function drawEllipse(centerX, centerY) {
  context.clearRect(0, 0, 600, 500);
  var height = Math.sqrt((width * width) - (focal * focal));
  var eccen = ((focal) / (width));

  context.fillText("Eccentricity = " + eccen.toFixed(2), 20, 40);
  context.fillText("Focal Width = " + focal, 20, 70);
  context.fillText("Major Axis = " + width, 20, 100);
  context.fillText("Minor Axis = " + height.toFixed(2), 20, 130);
  context.fillRect(centerX - (focal / 2.0), centerY, 2, 2);
  context.fillRect(centerX + (focal / 2.0), centerY, 2, 2);
  volume.value = focal;

  var a = width / 2.0;
  var b = height / 2.0;
  for (var t = 0; t < 360; t++) {
    var theta = t * Math.PI / 180;
    context.fillRect(centerX + a * Math.cos(theta), centerY + b * Math.sin(theta), 2, 2);
  }
  focal++;
  if (focal >= 200) {
    clearInterval(timer);
    context.fillStyle = "#BBB";
    context.fillRect(18, 145, 145, 20);
    context.fillStyle = "#FFF";
    context.fillText("Click to repeat", 25, 160);
    context.fillStyle = "#4D5C6D";
  }
}
document.getElementById('canvas1').addEventListener('click', function() {
  clearInterval(timer);
  focal = 0;
  timer = setInterval(function() {
    drawEllipse(300, 250)
  }, 50);
});

This piece of HTML code features a simulation showcasing the eccentricity of an ellipse.

Answer №1

It's unclear what your goal is in this situation.

If you're trying to determine the order of views, consider incorporating z-index into your CSS styling. A higher z-index value will bring a view to the front.

Answer №2

Tim Wilson and Jeff Vdovjak provided the solution, suggesting to change .wrapper > input to relative.

.wrapper > input {
    position:relative;

Their responses were:

Tim Wilson: What if we switched the position of .wrapper > input to relative instead of absolute?

Jeff Vdovjak: Hello Felipe, on stackoverflow. The .wrapper class currently has a position: absolute, which removes it from the page flow and places it over existing content. Consider removing the absolute positioning and using only position: relative instead.

Thanks for the help!

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

Overlay jQuery Accordion

I am currently working on an accordion to display old blog posts. However, when using a tab, the section below either moves or jumps around. I want the tab to lay over the rows below it without affecting their position. I have tried various solutions in ...

Can AJAX calls be used to accurately retrieve REMOTE_ADDR?

I am using an API in PHP to check the IP address from which calls are being made with REMOTE_ADDR. I want to whitelist all calls coming from IP address "A". For example, if I have an ajax call to myapi.com/controller/action/ and the AJAX JavaScript file i ...

Having trouble locating the name 'div' when starting a new React project?

After creating a new React application using the command: "npx create-react-app poi-search --template typescript", ESLint prompted me for permission and then displayed several errors. You can view the screenshot here. I am currently using the latest versi ...

Interacting with YouTube Data API without requiring user input

I'm currently developing a music website that enables users to create YouTube playlists. Initially, I experimented with JavaScript: https://developers.google.com/youtube/v3/code_samples/javascript The procedure involves an initial authorization ste ...

React Native query: What could be causing the inability to pass parameters (props) to my screen when utilizing stack navigator?

App.js const Stack = createNativeStackNavigator(); export default function App() { return ( <Provider store={store}> <NavigationContainer> <Stack.Navigator initialRouteName="Main"> <Stack.Screen ...

Using Bootstrap 4 to create columns with fixed width and displaying the rest of the line in the card-footer

I have a bootstrap-4 card containing a footer. The footer consists of a fixed-width input field and a button. The button needs to expand to the width of 100% minus the width of the input field. https://jsfiddle.net/aq9Laaew/224543/ input { width:3rem; ...

Limiting the Frequency of Event Triggers: How to Improve Efficiency

let time = null; let bounds = null; google.maps.event.addListener(map,'bounds_changed',function(){ bounds = map.getBounds(); time = (new Date()).getTime(); setTimeout(function(){ let now = ((new Date()).getTime() - 999); ...

How can I enhance this conversion function from an Array to an Object in JavaScript?

Looking to construct an object consisting of empty arrays using values as keys. const CATEGORIES = ['apple', 'banana', 'orange'] generateCategoryObject() === { apple: [], banana: [], orange: []} function generateCategoryO ...

What is the reason for innerHTML not functioning properly when trying to include HTML?

Apologies for my poor English, but I am determined to solve this issue using HTML code. <body> <div id="booklist"> <?php include("../templates/nav.php"); ?> <div class="hero"> <?php include("../templates/aside.ph ...

What is the recommended location for creating an Index in mongoose database?

Currently delving into techniques for enhancing Mongoose query performance as I develop my Node.js API. Recently discovered the benefits of utilizing Mongoose Indexes. My inquiry pertains to the optimal location for creating an Index within a schema. Would ...

Unable to prolong TypeScript document

As I develop a drag and drop interface, upon dropping a file, the native File is retrieved. To enhance this interface with additional information, I decided to explore various approaches. In my initial attempt, I utilized: interface AcceptedFile extends ...

What is the process for triggering a PHP function when a form element is clicked in a webpage?

Currently, I am trying to implement a jQuery colorbox on my webpage which appears over a <select> drop-down list. My goal is to trigger an AJAX call every time a new option is selected from the drop-down. Even though I have written the following cod ...

The auto-filled form is not displaying the selection options correctly

Issue with the form selection box. I am currently developing a form and I want it to automatically submit once an option is chosen. The following codes are implemented: <script> function designate_popup(form) { w = window.open('', &apos ...

"Enhance your listening experience with an audio player featuring album covers as captivating

Is there a way to create an audio player with the album cover image serving as the background, while ensuring all control buttons are displayed on top of that same image? I attempted using the following code snippet: <audio controls = 'controls&ap ...

The value of the jQuery data on click event handler becomes 'undefined' when used within an AJAX handler

When I click on the Positive or Negative buttons, a jQuery event handler function is triggered. Each button passes different data objects to the handler. However, within the AJAX POST handler, I am unable to access the data from the click event. $('# ...

What sets usePreloadedQuery apart from useQueryLoader?

I've been exploring graphQL and the react-relay library. These are the key points I've covered: Rendering Queries: where usePreloadedQuery is introduced. Fetching Queries for Render: where useQueryLoader is introduced. To keep it simple, I&apo ...

Is there a way to display the output of jQuery in an input box rather than a span?

I need to display the result of this function in an input box instead of a span tag because I plan to utilize the result in the following form. function checkChange(){ $.ajax({ url: "ordercalculate.php", data: $('form').seria ...

The size of the div adjusts post sliding action

I have a unique little script that I've included below which is designed to add a series of divs to a sliding panel triggered by a button click. <script type="text/javascript"> // Clicking the button initiates the slide for the panel. $ ...

Issue with Vue-ChartJS where adding datasets does not refresh the chart display

I am currently utilizing Vue-ChartJS to showcase a chart on my website. However, I have encountered an issue when trying to update the datasets using the Push Function - the chart does not update as expected (even though it should according to the document ...

Select the small image to reveal the larger overlay image

I have a grid of images and I want each image to expand into fullscreen when clicked. However, the JavaScript I am using is causing only the last image in the grid to overlay. How can I resolve this issue? Here is the code I am currently using: http://js ...