The HTML elements on the webpage are showing up incorrectly

When visiting thedaystaragency.com/home and scrolling down to our services section where the lightbulbs are located, it is apparent that they are misaligned and not functioning properly. I have provided the code that I am currently using, but I had to remove the button temporarily because there seems to be an issue with Elementor not allowing the button to work correctly. Any recommendations for a solution would be greatly appreciated! :)

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8>
<title>Change Image on Hover in CSS</title>
<style>
#myBtn{
  padding: 15px 25px;
  font-size: 24px;
  text-align: center;
  cursor: pointer;
  outline: none;
  color: #fff;
  background-color: #4CAF50;
  border: none;
  border-radius: 15px;
  box-shadow: 0 9px #999;
}

#lightbulb:hover img{
    content:url("https://thedaystaragency.com/wp-content/uploads/2020/03/rsz_11logomakr_2srycx.png");
}
  
  
#lightbulb:hover p { font-weight:bold; }
}
</style>
</head>
<body>
    <center>
    <div id=lightbulb >
 <img src="https://thedaystaragency.com/wp-content/uploads/2020/03/rsz_4rsz_logomakr_3ijkr2.png" onmouseover=this.src="https://thedaystaragency.com/wp-content/uploads/2020/03/rsz_11logomakr_2srycx.png" onmouseout=this.src="https://thedaystaragency.com/wp-content/uploads/2020/03/rsz_4rsz_logomakr_3ijkr2.png" width=25px;> <br> <br> <h2> hi</h2> <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Phasellus imperdiet, nulla et dictum interdum, nisi lorem egestas vitae scel<span id="dots">...</span><span id="more">erisque enim ligula venenatis dolor. Maecenas nisl est, ultrices nec congue eget, auctor vitae massa. Fusce luctus vestibulum augue ut aliquet. Nunc sagittis dictum nisi, sed ullamcorper ipsum dignissim ac. In at libero sed nunc venenatis imperdiet sed ornare turpis. Donec vitae dui eget tellus gravida venenatis. Integer fringilla congue eros non fermentum. Sed dapibus pulvinar nibh tempor porta.</span></p>

}

Regarding the button, I am attempting to achieve something similar to this:

<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<style>
#more {display: none;}
</style>
</head>
<body>

<h2>Read More Read Less Button</h2>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Phasellus imperdiet, nulla et dictum interdum, nisi lorem egestas vitae scel<span id="dots">...</span><span id="more">erisque enim ligula venenatis dolor. Maecenas nisl est, ultrices nec congue eget, auctor vitae massa. Fusce luctus vestibulum augue ut aliquet. Nunc sagittis dictum nisi, sed ullamcorper ipsum dignissim ac. In at libero sed nunc venenatis imperdiet sed ornare turpis. Donec vitae dui eget tellus gravida venenatis. Integer fringilla congue eros non fermentum. Sed dapibus pulvinar nibh tempor porta.</span></p>
<button onclick="myFunction()" id="myBtn">Read more</button>

<script>
function myFunction() {
  var dots = document.getElementById("dots");
  var moreText = document.getElementById("more");
  var btnText = document.getElementById("myBtn");

  if (dots.style.display === "none") {
    dots.style.display = "inline";
    btnText.innerHTML = "Read more"; 
    moreText.style.display = "none";
  } else {
    dots.style.display = "none";
    btnText.innerHTML = "Read less"; 
    moreText.style.display = "inline";
  }
}
</script>

</body>
</html>

Answer №1

I would suggest avoiding the use of bold text for an entire paragraph. Instead, you could consider something like the following:

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8>
<title>Change Image on Hover in CSS</title>
<style>
#myBtn{
  padding: 15px 25px;
  font-size: 24px;
  text-align: center;
  cursor: pointer;
  outline: none;
  color: #fff;
  background-color: #4CAF50;
  border: none;
  border-radius: 15px;
  box-shadow: 0 9px #999;
}

#lightbulb:hover img{
    content:url("https://thedaystaragency.com/wp-content/uploads/2020/03/rsz_11logomakr_2srycx.png");
} 
  
#lightbulb:hover p { 
  box-shadow: -26px 10px 37px -4px rgba(220,220,220,1);
  background-color: rgba(204, 245, 245, 0.5);
}

.text {
  box-sizing: border-box;
  padding: 5px;
  text-align: justify;
  transition-duration: 700ms;

}

</style>
</head>
<body>
    <center>
    <div id=lightbulb >
 <img src="https://thedaystaragency.com/wp-content/uploads/2020/03/rsz_4rsz_logomakr_3ijkr2.png" onmouseover=this.src="https://thedaystaragency.com/wp-content/uploads/2020/03/rsz_11logomakr_2srycx.png" onmouseout=this.src="https://thedaystaragency.com/wp-content/uploads/2020/03/rsz_4rsz_logomakr_3ijkr2.png" width=25px; <br> <br> <h2> hi</h2> <p class="text">Lorem ipsum dolor sit amet, consectetur adipiscing elit. Phasellus imperdiet, nulla et dictum interdum, nisi lorem egestas vitae scel<span id="dots">...</span><span id="more">erisque enim ligula venenatis dolor. Maecenas nisl est, ultrices nec congue eget, auctor vitae massa. Fusce luctus vestibulum augue ut aliquet. Nunc sagittis dictum nisi, sed ullamcorper ipsum dignissim ac. In at libero sed nunc venenatis imperdiet sed ornare turpis. Donec vitae dui eget tellus gravida venenatis. Integer fringilla congue eros non fermentum. Sed dapibus pulvinar nibh tempor porta.</p>

Answer №2

Upon trying out this solution, I was pleasantly surprised to find that it actually worked! Your insight was truly valuable.

`enter code here`<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8>
<title>Changing Image on Hover with CSS</title>
<style>

#gears:hover img{
    content:url("https://example.com/image2.png");
}
#gears img { padding-bottom:15px;
}

  #gears p{ font-family:raleway;
  font-size:15px;
  font-weight:400;
  }
  
  #gears h2{ font-family:raleway;
  font-size:20px;
    font-weight:400;
  }

  
  #gears:hover h2{ color:#04A4CC; }
}


</style>
</head>
<body>
    <br>
    <center>
    <div id=gears >
 <img src="https://example.com/image1.png" onmouseover=this.src="https://example.com/image2.png" onmouseout=this.src="https://example.com/image1.png" wwidth=45px; <br> <br> <h2> OPERATIONAL CONTROLS</h2> <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nulla vestibulum ut ligula sed consequat. Maecenas blandit lorem eu leo molestie, a bibendum tortor commodo. Proin hendrerit sapien vel vulputate ultricies. Sed at efficitur neque. Mauris orci nulla, malesuada id egestas eget, tincidunt ac odio. Nam eleifend lectus in ex accumsan congue. Nulla facilisi. Etiam suscipit mi vitae turpis tempus volutpat. Aenean libero nibh, rutrum nec pretium sit amet, interdum et nulla.<br>
 [expand title="Read More" swaptitle="Close" trigpos="below" trigclass="my_button"]
 Ut quis tellus nec nisl faucibus semper. Phasellus demonstrates sollicitudin diam, in fermentum arcu blandit id. Integer aliquam mattis justo et maximus. In congue urna sit amet lacus feugiat sagittis. Donec finibus nisi dui, in imperdiet risus tristique non. Sed vel ante cursus, consectetur quam vitae, venenatis erat. Suspendisse potenti. Aliquam rhoncus elementum mauris, eget condimentum velit mollis nec. Curabitur et felis ornare, pharetra augue id, varius est. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Fusce viverra eleifend sodales. Morbi gravida eget purus nec lobortis. Cras at metus nec eros placerat vehicula.
 [/expand]</p> <br>
          

Answer №3

I'm not quite sure of your intention, but the issue with misalignment is caused by the final light bulb division not being enclosed within the identical structure as the initial three.

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

Javascript ajax async data update has encountered a failure

Utilizing HTML, javascript, and Nodejs coding to create a chrome extension. When the page loads, the function getBalance() is invoked to retrieve data and display it in an HTML span. Below is the code snippet: function getBalance() { var request = new ...

Encountering a CSS syntax error within CodeSandbox when attempting to input code within brackets

Why is it that I don't see syntax errors in VSCode, but always encounter them in CodeSandbox? What could be causing this discrepancy and how can I resolve it? Any advice would be greatly appreciated. Thank you in advance. Here's an example of th ...

Choose everything except for the list and its heading

I have a portion of HTML code on my hands. <div class="ProductDescriptionContainer"> <p>This handsome Clergy Shirt has a trim low neckband with two reinforced buttonholes, one at the front, one at the back, to align with Ziegler's Collare ...

Dynamic properties in JQuery

Here is the HTML DOM element I have... <input type="text" style="width: 200px;" id="input1"/> I want to make sure it stores date values. How can I specify that in the DOM element? Please provide your suggestions. Thanks! ...

Transitioning JS/CSS effects when the window is inactive

My latest project involved creating a small slider using JavaScript to set classes every X seconds, with animation done through CSS Transition. However, I noticed that when the window is inactive (such as if you switch to another tab) and then return, the ...

Unable to save cookies on mobile browsers, but functioning properly on desktop computers

Currently, I am facing an issue with my ExpressJS app hosted on Heroku and a frontend React app hosted on Netlify. The problem arises when a user logs in successfully and is directed to the home page showing personalized content. Upon landing on the home p ...

Why does console.log in JavaScript exhibit different behaviors as evidenced by the code?

Exploring the behavior of console.log(obj) compared to console.log("obj"+"\n"+obj) in the code snippet below reveals two distinct output outcomes. const obj = new Object() obj.first = 'John' obj.last = 'Doe' obj.alive = true ob ...

discovering a new type of mutation through the use of Vuex

Vue Component computed: { score () { this.$store.commit('fetchCoordinates'); console.log(this.$store.getters.cordinate); } } store.js export default { state: { lat:'ok', }, getters:{ cordinate(state){ r ...

Issue with rgba background color not working in Bootstrap 3 navbar

Attempting to change the background color of bootstrap's navigation bar to a lower opacity rgba one, but facing difficulties. There are no changes being reflected at all. Below is the custom navbar CSS: .navbar-custom { background-color: rgba(255 ...

Using pg-promise to insert a UUID into the database

I am in the process of setting up a new server and I want each customer to have a unique UUID identifier. My goal is to allow the customers name, parent company, and internal id to be input through a web interface, while the UUID is generated on the server ...

When my viewport's size is less than 998px, a blank space appears

While configuring media queries in my HTML and CSS project, everything seemed to be working well. However, I noticed that when I shrink the screen, there is an empty white space on the right side and a horizontal scroll bar appears at the bottom without an ...

What is causing the error in this particular stream function?

I created a function that logs the provided arguments to the console when piped into it. function logToConsole() { var stream = new Stream.Transform({objectMode: true}), args = [].slice.call(arguments); stream._transform = function (data, ...

What are some possible reasons or solutions for Axios sending a 404 error?

Hi there, I'm completely new to the MERN stack and I'm encountering an issue when trying to post data using Axios and Express. I may have misunderstood something, so here's my problem. I have a form on a page that I am attempting to use to s ...

Creating a gap between two elements without using the space-between property

Currently working on creating a responsive menu, <div style={{ display: "flex", flexFlow: "row wrap" }}> {/* left side */} <div key="1">nav 1</div> <div key="2">n ...

What is the method for calculating table cell widths in HTML?

Take a look at this code snippet here: http://jsfiddle.net/R3AKT/1/. <table class="main"> <colgroup><col class="votes"><col></colgroup> <tr> <td>Votes</td> <td>Comments</td> </tr ...

Looking to set up an event handler for the browser's back button in next.js?

When my modal opens, it adds a hash to the URL like example.com/#modal. I want to be able to recognize when the back button is clicked in the browser so I can toggle the state of the modal. The challenge is that since I am using next.js (server-side rend ...

Utilize Meteor-tabular to effortlessly export data with convenient HTML5 export buttons

Currently, I am utilizing the tabular package to display data from a collection in a table format. However, when attempting to export the data using html5 export buttons with the button (csvhtml5), only the length of data visible in the table is exported, ...

Issues with applying styles to custom components in styled-components

I attempted to customize the inner elements of react-id-swiper using the code below: import Swiper from 'react-id-swiper'; import styled from 'styled-components'; const MySwiper = ({ className, children }) => ( <Swip ...

What is the proper way to indicate the pointer to the current element within the array?

How can I modify a code that displays a list of posts? import React from "react"; type respX = { "id": any, "userId": any, "title": any, "body": any, } interface PropsI { } interface StateI { data: respX []; } export class Compone ...

Is it possible to have Mobile WebKit store the click position?

I am in the process of developing a unique framework specifically designed for WebKit devices. One of the features I have implemented is a series of list views that activate a 'hover' class when users touch them. Below is the jQuery/JavaScript co ...