Tips for positioning a table at the bottom within a DIV:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<style>
.square
{
 width: 200px;
 height:200px;
 background-color:#F99; 
}

#myimage {
    position: absolute;
    top: 0;
    left: 0;
    z-index: 10;
}

.table
{
    position:relative;
    margin-top:80px;

}
</style>
<script>

cc=1;
function changeimage()
{
if (cc==0) 
  {
  cc=1;
  document.getElementById('myimage').src="images/white_contact.png";
  }
else if (cc==1)
  {
  cc=2;
  document.getElementById('myimage').src="images/yellow_contact.png";
  }
  else if (cc==2)
  {
  cc=3;
  document.getElementById('myimage').src="images/red_contact.png";
  }
    else
  {
  cc=0;
  document.getElementById('myimage').src="images/green_contact.png";
  }
}
</script>
</head> 

<body>
<div class = "square">
<table border="0" class = "table" ><tr>
<td width="51">Name:</td>
<td width="141"><input type="text" size="10"></td>
</tr>
<tr>
<td>Title:</td>
<td><input type="text" size="10"></td>
</tr>
<tr>
<td>Contact:</td>
<td><input type="text" size="10"></td>
</tr>
</table>
</div>
<img id="myimage" onclick="changeimage()" border="0" src="images/white_contact.png" width="70" />

<p>Click to turn on/off the light</p>

</body>
</html>

I am facing an issue with positioning my table at the bottom of the pink box, it keeps getting blocked by the image. I have tried adjusting my CSS but it still stays at the top. What should I do? Can someone help me?

Answer №1

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<style>
.square
{
 width: 200px;
 height:200px;
 background-color:#F99; 
 position: absolute;
}

#myimage {
    position: absolute;
    top: 0;
    left: 0;
    z-index: 10;
}

.table
{
    bottom: 0;
    position: absolute;
    margin-top:80px;

}
</style>
<script>

cc=1;
function changeimage()
{
if (cc==0) 
  {
  cc=1;
  document.getElementById('myimage').src="images/white_contact.png";
  }
else if (cc==1)
  {
  cc=2;
  document.getElementById('myimage').src="images/yellow_contact.png";
  }
  else if (cc==2)
  {
  cc=3;
  document.getElementById('myimage').src="images/red_contact.png";
  }
    else
  {
  cc=0;
  document.getElementById('myimage').src="images/green_contact.png";
  }
}
</script>
</head> 

<body>
<div class = "square">
<table border="0" class = "table" ><tr>
<td width="51">Name:</td>
<td width="141"><input type="text" size="10"></td>
</tr>
<tr>
<td>Title:</td>
<td><input type="text" size="10"></td>
</tr>
<tr>
<td>Contact:</td>
<td><input type="text" size="10"></td>
</tr>
</table>
</div>
<img id="myimage" onclick="changeimage()" border="0" src="images/white_contact.png" width="70" />

<p>Click to turn on/off the light</p>

</body>
</html>

Answer №2

Make sure to modify the current classes in your document with the following styles.

 .rectangle {
    width: 300px;
    height: 150px;
    background-color: #F99;
    display: flex;
 }

 .flex-container {
    align-items: center;
    display: flex;
 }

Answer №3

To effectively align elements to the bottom of their parent container, follow these guidelines...

.parent {
    display: table-row;
}

.child {
    display: table-cell;
    vertical-align: bottom;
}

Remember to use the vertical-align: bottom rule for proper alignment. Keep in mind that this may not work with block-level elements like <div>, so you'll need to adjust the display settings accordingly, such as using table.

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

Issues with forms displaying as raw text within Laravel 5

I recently entered the realm of Laravel. While following a tutorial on OpenClassrooms, I encountered some challenges as the tutorial was for Laravel 4 and I am using Laravel 5. After struggling to adapt my controllers and resolve namespace dependency erro ...

There seems to be an issue with the rangeslider.js jQuery plugin not being recognized as a function within the project. However, there are

I am currently working on integrating a Range-slider into my Django project with the help of rangeslider.js. I was able to successfully create a functional example on Codepen at https://codepen.io/Slurpgoose/pen/GRRpmpX, and everything seemed to be running ...

Trigger javascript code upon the clicking of a hyperlink

I need to trigger a JavaScript function after clicking on a specific link on my webpage. I came across this code snippet: <a href="#" id="myHref">Click me</a> $("#myHref").on('click', function() { document.getElementById(".myDiv").s ...

The Jquery animate function is not compatible with the transform property

I am facing an issue with the Jquery animate function. Despite trying various solutions, I have been unable to get it to work. Below is the HTML code that I have used: <!DOCTYPE html> <html lang="en"> <head> <meta cha ...

Attributes are lost from button within Bootstrap popover

I have integrated a bootstrap popover into my Django website, which pops up upon clicking a button. Inside this popover, there is another button. To achieve this functionality, I have included HTML within the 'data-content' property of the popove ...

How can I modify the value of a CSS animation rule in AngularJS?

I am looking to dynamically change the value assigned to stroke-dashoffset based on a custom input. @-webkit-keyframes donut-chart-1 { to { stroke-dashoffset: 100; } } @keyframes donut-chart-1 { to { stroke-d ...

What is the best method for adding a line break in the body of an email when we include the recipient, subject, and message?

Do you have a requirement where information needs to be sent to an end user via Gmail (preferred) and they need to click on a button in the email body to respond? The button response is set up with predefined to, subject, and body fields, but there are dif ...

What causes the unexpected behavior of JQuery's .animate() function?

I am currently working on a project that involves creating a div element for the purpose of dragging and dropping files. My goal is to have the height of the div increase when a file is dragged into it, and decrease when the file is dragged out. To achiev ...

Is there a way to reset a value back to its original user agent default?

When utilizing the initial value, I have the ability to designate an element's CSS property to its initial value per the specification. However, there are instances where I may prefer to set a CSS property to its initial user agent value instead. Fo ...

Determine if the grid is accurately sorted in sequence using Cypress

I am currently working on sorting images based on their order, with the options for new and old. The [data-cy="list-file"] wraps all the images, while [data-cy=fileCard-list] represents each individual image. After selecting the 'old' b ...

Using jQuery to eliminate the final input field in a dynamic list

I'm struggling to figure out how to remove the last <div><input type="text" name="mytext[]"></div> even when using the "top" button for removal. Currently, when I create multiple fields and click the "remove" icon at the top of them, ...

Create an interactive form within an HTML table by dynamically adding text fields

$(document).ready(function() { var maxField = 10; var addButton = $('.add_button'); var wrapper = $('.field_wrapper'); var fieldHTML = '<div><input type="text" name="Tape_Code[]" value=""/><a href="javascript ...

I'm looking to update the text within this alert notification box. Can you provide the appropriate code for my custom css to achieve this?

Looking for some help...I want to update the text in this alert warning box. Can anyone provide the correct code to add to my custom CSS? I've been trying different things but can't seem to get it right, feeling a bit embarrassed. view image des ...

Is there a way to reveal multiple inputs by simply pressing a button?

Currently, I am working on developing a website using HTML, CSS, and JavaScript. As part of the process, I am looking to implement a login interface. I have already included some input fields and written a sign-in.js script that verifies whether a user h ...

Refreshing HTML content using event delegation in JavaScript

Currently, I am attempting to dynamically load additional HTML content onto my webpage when a button is clicked. Here is the code that I have implemented so far: Main HTML Code: <div class="row" id="gallery-wrapper" > <di ...

Flask-WTForms QuerySelectField not displaying properly when rendered with Bootstrap causing <select> HTML tag issue

I am facing an issue while constructing a Flask form that includes a QuerySelectField. Despite having everything in place, Bootstrap is displaying the <select> as if it were a text input field. Upon inspecting the page source, I noticed that the fie ...

How can I center the carousel on the page?

<div id="imageCarousel" class="carousel slide" data-interval="3000" data-ride="carousel"> <ol class="carousel-indicators"> <li data-target="#imageCarousel" data-slide-to="0" class="active"></li> ...

Prevent images from displaying on smaller screens by utilizing Bootstrap's responsive design

Here is a snippet of code that utilizes Bootstrap 4 to display text and images: <div class="container"> <div class="row"> <div class="col-xl-12"> <img src="~/img/img1.png" style="height:60.3px;width:750px" clas ...

Overlay one image on top of another

Recently, I've been working on this code snippet. I am attempting to center the profile picture even when the screen width is reduced. The issue lies with using position:absolute, preventing margins:auto from functioning properly. As a workaround, I ...

Trouble with Click event not working in Electron and mouse cursor not changing when hovering over an HTML button?

I'm in the midst of a project that involves using the electron framework. Within my project, I have an HTML file, a CSS file, and a Javascript file. The issue at hand is that when I hover over a button, the expected hand pointer icon fails to appear d ...