The text within my div is spilling over the edges despite my attempts to use text align and overflow properties

body {
  font-family: Arial;
  font-size: 15px;
}

.container {
  position: relative;
  max-width: 1800px;
  height: auto;
  margin: 0 auto;
  text-align: center;
  width: 90%;
}

.container img {
 vertical-align: center;
}

.container .content {
  position: absolute;
  background: rgb(2, 2, 2);
  background: rgb(5, 5, 5, 0.5);
  color: rgb(255, 230, 0);
  width: 100%;
  padding: 5px;
  text-align: center;
  bottom: 0;
  overflow: hidden;
}
<div class="container">
  <img src="https://sample-image.com" alt="Sample Image" style="width:90%;">
  <div class="content">
    <h2>The Dragon</h2>
    <p>“Forget about winning and losing; forget about pride and pain. Let your opponent graze your skin and you smash into his flesh; let him smash into your flesh and you fracture his bones; let him fracture your bones and you take his life! Do not be concerned
      with escaping safely- lay your life before him!!”.</p>
  </div>
</div>

Answer №1

To ensure it fills the entire screen, you can specify a minimum height for the body element of 100vh. If you'd like the text on top instead of at the bottom, simply rearrange the HTML structure so that the content div comes before the image.

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

"Enhance User Experience with the jQuery/JavaScript Table Pagination

I have searched extensively for a jQuery/JavaScript table pagination solution. While I found some options, they were too complex for my needs. I am looking for a simple jQuery plugin to assist with paginating an HTML table. Datatables is more than what I ...

What is the reason for the disparity in the way a form type is displayed?

Two versions of a small project exist, 'webpack' and 'retro'. The webpack version utilizes ../app.scss/...@import "~bootstrap/scss/bootstrap"; for serving styles (css), while the retro version uses the outdated <link rel=&q ...

Comparing DOM Creation in PHP and JavaScript

My website currently does not have any ajax requests, and here is a simplified version of my code: class all_posts { public function index($id){ $statement = $db->prepare("SELECT * FROM mytable WHERE id = :id"); $statement->exe ...

Tips on accessing a particular value from an HTML header

My current task involves using selenium to extract request headers from a web page. However, I am facing an issue where all request headers are being printed out, whereas I only need one specific value from them. Despite searching online, I have been unabl ...

Ways to initiate a transition upon clicking a button, causing it to switch from being hidden (`display: none`) to visible (`display: block`)

I'm attempting to create a smooth transition effect when a button is clicked, similar to a toggle function, where the content below it seamlessly shifts instead of abruptly moving. The classic example of this is the Bootstrap navbar hamburger menu, wh ...

Infinite scrolling feature on Kendo UI mobile listview showcasing a single item at a time

Currently, I am utilizing the kendo ui mobile listview and encountering an issue when setting endlessScroll or loadMore to true. The problem arises as the listview only displays the first item in such instances. Upon inspecting with Chrome inspector, I ob ...

Having Difficulty Applying a Background Color to a Class in Bulk

I am working on a unique HTML canvas for pixel art, which is created using a table made up of various divs all sharing the "pixel" class. I want to add a clear button that can reset the entire canvas, but changing the background color of each individual di ...

Is it possible to conceal an error message while another error message is being shown?

<form name="form"> <input type="password" placeholder="Password" ng-model="password" name="password" minlength="6" maxlength="15" ng-pattern="/^\S*$/" required> <span ng-show="form.password.$dirty && form.password.$in ...

Leveraging BeautifulSoup for retrieving targeted dl and dd item listings

Today marks my first time posting. I am currently utilizing BeautifulSoup 4 and Python 2.7 (PyCharm) to work on a webpage that contains various elements. Specifically, I am aiming to extract certain elements where the tags are either 'Salary:' or ...

Showing a variety of pictures within a specified time frame

In my CSS, I have defined classes that allow me to display different background images on a page at set intervals: .image-fader { width: 300px; height: 300px; } .image-fader img { position: absolute; top: 0px; left: 0px; animation-name: imagefade; ...

Having trouble with your HTML iFrame not functioning properly?

My code is not working as expected and I'm puzzled by it. It was working fine yesterday but now it's giving me trouble. <iframe allowfullscreen="" allowtransparency="true" frameborder="0" height="2000" scrolling="no" src="http://www.google.co ...

Modifying Checkbox BorderWidth in Material UI v5

Seeking assistance with adjusting the checkbox border width in Material UI v5. I currently have a custom checkbox and would like to remove the border width. Despite trying numerous solutions, I have been unsuccessful so far. checkbox <Checkbox de ...

Is the <a data-method='something' href ... requesting a POST method?

Yes, it does. Has this behavior been documented anywhere? Situation: I made an error with my RoR Helper and created Links with data-method='GET'. Everything still functioned correctly, but I received a "Resend Data Warning" when refreshing the ...

The horizontal scrollbar in PrimeNG's p-tree is cleverly concealed until I reach the bottom of the div and start scrolling

I'm facing an issue where the horizontal scrollbar in my p-tree component is hidden until I scroll all the way down. I've tried various CSS modifications, but nothing seems to work. It's surprising that I couldn't find anyone else with ...

Activate the Chrome Extension that allows you to open a link in a new tab with just a middle click or regular click, without closing the popup

When I try to click a link in my extension popup and open it in a new tab using "middle click -> open link in a new tab", the popup closes. Is there a way to keep the popup open so I can click on multiple links from my extension without interruption? A ...

Custom component not rendering expected CSS style

I have successfully developed a custom web component without using any framework. I then proceeded to populate it with content from a template tag. Although I was able to manipulate the content using JavaScript, I encountered difficulties when trying to m ...

Missing CSS in dynamically loaded content on IE

I have been searching everywhere, but I just can't seem to find a satisfactory answer to this particular question. Whenever I load a few items on the page, they are displayed correctly at first. However, if a user decides to change the language, the ...

Remove all HTML tags except for those containing a specific class

Looking for a regex that removes all HTML tags except the "a" tags with the "classmark" class For example, given this HTML string: <b>this</b> <a href="#">not match</a> <a href="#" target="_blank" ...

The base64 code generated by the toDataURL method on the canvas appears to be incorrect

I am facing an issue with my code while using canvas to draw a cropped image with base 64. The problem is that it works perfectly on Chrome but gives me a blank image on Firefox. async function base64SquareCrop(imgbase64, size = 224) { const img = docume ...