placing a see-through overlay onto a text-filled div

I have a text within a div and I am looking to overlay a transparent image on this div.

When the image is clicked, the content of the background div should be displayed with the div changing its width to show the entire text with a scroll bar. Does anyone have a solution for this?

Thank you in advance.

This is the code for the text div with a width of 400px :

<div class="about-style">
    <h2 class="about-header">About</h2><br><br>
    <p class="about-text-style">
    London, England’s capital, set on the River Thames, is a 21st-century city with history stretching back to Roman times. At its centre stand the imposing Houses of Parliament, the iconic ‘Big Ben’ clock tower and Westminster Abbey, site of British monarch coronations. Across the Thames, the London Eye observation wheel provides panoramic views of the South Bank cultural complex, and the entire city. times. At its centre stand the imposing Houses of Parliament, the iconic ‘Big Ben’ clock tower and Westminster Abbey, site of British monarch coronations. Across the Thames, the London Eye observation wheel provides panoramic views of the South Bank cultural com<br>
    <span class="more-text-class"> > more </span>
    </p>
    
    </div>

Answer №1

Here is a code snippet that may assist you:

$(".about-style img").click(function(){
$(this).hide();
$("div.about-style").addClass("DivWithScroll");;
});
.about-style img{
  position : absolute;
  top : 0;
}

.DivWithScroll{
    height:150px;
    overflow:scroll;
    overflow-x:hidden;
    padding : 10px;
    border : 1px solid red;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.10.1/jquery.min.js"></script>
<div class="about-style">
  <h2 class="about-header">About</h2>
  <p class="about-text-style">
    London, England’s capital, set on the River Thames, is a 21st-century city with history stretching back to Roman times. At its centre stand the imposing Houses of Parliament, the iconic ‘Big Ben’ clock tower and Westminster Abbey, site of British monarch coronations. 
    Across the Thames, the London Eye observation wheel provides panoramic views of the South Bank cultural complex, and the entire city. times. At its centre stand the imposing Houses of Parliament, the iconic ‘Big Ben’ clock tower and Westminster Abbey, site of British monarch coronations. 
    Across the Thames, the London Eye observation wheel provides panoramic views of the South Bank cultural com
    <span class="more-text-class"> <i class="fa fa-arrow-right"></i> more </span>
  </p>
  <img src="http://bluemarlinpools.com/wp-content/themes/twentytwelve/images/pool-background.png" width="100%" height="210px"/>
</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

jquery function that switches image after the fifth mouseover event

I just can't seem to figure this out. I need a mouseover event that switches between two images until the fifth time you mouseover, then it changes to a third image. Here is my code so far: <!doctype html> <html> <head> <meta c ...

Button with improperly aligned text

I'm having an issue with two buttons where the text on one button is not centered. .mail_download_csv_btn{ width: 100px !important; font-size: 12px !important; } .margin_right_10{ margin-right:10px; } <link rel="stylesheet" href="https: ...

utilizing AJAX in PHP for a dynamic selection process with MariaDB

I am working on a dynamic select feature using AJAX, PHP, and queries to a database. There are three main components involved in this process: the HTML where the select options are populated from database queries done through AJAX, the PHP scripts that han ...

The collapsing feature of the Bootstrap 4 Nav bar does not seem to work when testing locally

I am attempting to create a Collapsible Nav Bar using Bootstrap 4.0.0. I have included Bootstrap.min.css, bootstrap.min.js and jquery(3.2.1) in my project. However, when I view the page in a browser, the collapsing functionality is not working as expected ...

Recharge the Div

Looking for a solution to refresh the content within a specific div, I have implemented the following code: <script> $(function() { $("#refresh").click(function() { $("#new").load("/new.php") }) }) </script> The issue I am facing is ...

Guide on retrieving the button value within a foreach loop by utilizing the post method

Aim: Retrieve the values of buttons using the $_POST method within a foreach loop $projects= 'Project1, Project2, Project3'//from MySQL database $projectNames = explode(',', $projects); // separating project names to display individua ...

Angular 2 ngIf displaying briefly before disappearing

Encountering a strange issue with an Angular 2 ngIf statement where it appears on the page for a brief moment and then disappears. The content is visible, but it doesn't remain on the page. I suspect it might be related to some asynchronous behavior. ...

Search a location database using the user's current coordinates

Currently, I am working on a project that involves a database containing locations specified by longitude and latitude. Upon loading the index page, my goal is to fetch the user's location and then identify every point within a certain distance radius ...

Steps to Safely Transmit the Password through Ajax() Function in jQuery

I have implemented a Password textbox that starts with an empty value. When the user clicks on it and enters a password, the password will be updated in the database upon leaving the textbox (onblur event). I have successfully achieved this using ajax(). H ...

What is the best way to attach every sibling element to its adjacent sibling using jQuery?

I've been working with divs in Wordpress, where each div contains a ul element. <div class="list-item"> <div class="elimore_trim"> Lorem ipsum </div> <ul class="hyrra-forrad-size-list"> <li>Rent 1< ...

Changing the direction of the cursor to move opposite of the mouse's input

I'm currently working on a unique webpage with an unconventional navigation method. The concept involves the cursor moving in the opposite direction of mouse movement input. To achieve this effect, I decided to hide the actual cursor and use JavaScri ...

What could be causing the "no such file" error to occur while attempting to use the "mammoth" tool to convert a basic .docx file?

Here is my code snippet. The file contains a basic "hello world" and I have the hello.docx file located in the same directory where I am running this mammoth function. Error message: fatal Error: ENOENT: no such file or directory, open './hello.docx& ...

The FAB button animation is causing delays in the transition process and is not functioning as originally anticipated

I am facing an issue with the FAB button and 3 Icons. The functionality is working fine on click for both show and hide actions, but the transition is too delayed. I want the icons to appear step by step, even though I have adjusted the transition delay se ...

Clicking on the Submit button of the post form simply refreshes the page

Every time I try to submit values from an HTML form, the page reloads without any changes. I've double-checked the routes and controller, but everything seems correct. Solution <div class="panel-body"> @if (session('status')) ...

Design a div in the shape of a trapezium with clipped overflow

Is there a way to create a trapezium using CSS/Html/Canvas? I have attempted to do so, but my current method is messy and not practical. div { width:0; margin-left:-1000px; height:100px; border-right:1000px solid lightblue; border-top:60px solid tra ...

Encountering issues while trying to install Java using NPM

Encountering errors when attempting to run the following command to install java dependencies for NPM. NPM install -g java In need of assistance to fix this error. C:\WINDOWS\system32>npm i -g java [email protected] install C:\D ...

Vue Apollo Composable useQuery Does Not Respond to Dynamic Changes in Filter Variables Despite Triggering a Refetch

Currently utilizing Vue Apollo Composable along with useQuery for executing a GraphQL query. Pagination is functioning correctly; however, encountering an issue with the filters.verified variable. Although the variable appears to toggle on the client-side ...

Using Selenium WebDriver to Extract Variables from JavaScript SourceCode

Currently, I am dealing with a web page source code that utilizes JavaScript to display text. Below is an excerpt from the source: var display_session = get_cookie("LastMRH_Session"); if(null != display_session) { document.getElementById("sessionDIV") ...

What's the reason behind the presence of the a tag before the button in this

While working with Bootstrap 4, I noticed that the a tag is being displayed before the button when using the following code. Can anyone explain why? <button class="navbar-toggler hidden-sm-up" type="button" data-toggle="collapse" data-target="#navbar ...

"I am encountering an issue where I am using React and Express to retrieve data from a database, and although I am able to return an array of

I am working on a React app that communicates with an API using Express. Currently, I am using the GET method to fetch data from a database, and my fetching code looks like this: const posts = []; fetch(URL) .then(response => response.json()) .then(jso ...