Arranging elements on a CSS grid with overlapping placements

I have a comments box that overlaps an image and should remain fixed to the bottom of the image. However, the 'existing-comments-container' keeps stretching to the end of the page instead of just across the width of the image container as expected.

Check out this image for better clarification:

https://i.sstatic.net/Ct7Uk.jpg

Take a look at the relevant HTML code snippet below:

<div class="overlay">
  <div class="full-view-container">
        <div class="overlay-inner-portrait">
            <img [src]="image.imagePath" alt="photo" (click)="closeImage()">
        </div>
        <div class="existing-comments-container">
            <div class="existing-comments" *ngFor="let comment of comments">
                <p class="commentor-name">{{comment.name}}</p>
                <p class="comment">{{comment.usersComment}}</p>
            </div>
        </div>
</div>

And here is the relevant CSS styling:

.overlay {
    position: fixed;
    background: rgba(0, 0, 0, 0.7);
    top: 0;
    right: 0;
    bottom: 0;
    left: 0;
    display: none;
    z-index: 4;
    display: grid;
    align-items: center;
    justify-items: center;
    grid-template-columns: 1;
    grid-template-rows: 1;
  }

 .full-view-container {
      display: grid;
      grid-column: 1 / -1;
      grid-row: 1 / -1;
      display: grid;
      grid-template: 1fr / 1fr; 
  }

  .overlay-inner-portrait {
    background: white;
    width: 450px;
    height: 580px;
    padding: 20px;
    grid-column: 1 / -1;
    grid-row: 1 / -1;
    display: grid;
    grid-template: 1fr / 1fr;
    align-items: end;
  }

.overlay img {
    width: 100%;
    height: 100%;
  }

  .existing-comments-container {
    display: grid;
    grid-template-columns: 1fr;
    grid-column: 1 / -1;
    grid-row: 1 / -1;
    align-self: end;
    justify-items: center;
    max-height: 100px;
    background: white; 
}

Answer №1

The reason behind the problem was identified as the lengthy text within a user's comment box, leading to the boxes stretching beyond normal. To fix this, I implemented a max-width property on the p tag associated with the .comment class.

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

Tips for Choosing Certain List Items in a Responsive Bootstrap Navigation Menu for WordPress

I've put together a sleek bootstrap navbar menu for WordPress. If you want to check out the menu design, you can view it by clicking on this link: here There are still some tweaks that need to be made though. Specifically, I need to add a box around ...

Placing two items at opposite extremes of a full-width display with a header

Despite the abundance of resources on CSS positioning, I constantly find myself revisiting this topic because it continues to perplex me with no clear solution in sight. Let's simplify things. Imagine a header div with a width of 100%, like this: &l ...

A step-by-step guide to updating the background color in JavaScript when a button is clicked

I successfully changed the text color, however, I am struggling to figure out how to change the background color of the p tag. If anyone could provide guidance on how to accomplish this, it would be greatly appreciated. Below you will find my HTML and JS c ...

Altering the vertical position of <li> within the nav bar without impacting the size of the nav bar is proving to be a

How can I adjust the vertical position of li elements without impacting the height of the navigation bar? Below is the code snippet in question: body { margin: 0px; } ul { margin: 0px; padding: 0px; list-style: none; padding-left: 5px; pad ...

Creating an image slideshow with a looping JavaScript array: Step-by-step guide

One issue with the program is that when it runs, only the last array value image is displaying on the screen while the other images are not. Below is the HTML code: <img id="mg" alt="image not found"> And here is the JavaScript code: var images=[ ...

Leverage GPU Acceleration in CSS for background animation

I've been experimenting with utilizing GPU accelerated CSS to animate the background image on my webpage for a few days now. Can someone guide me on the code required to achieve this? I've come across transform3d(0,0,0) in my research, but I&apos ...

Is there a way to change the color of the menu button to white if the points are not visible?

I have created CSS to style the menu's color and make the buttons change color based on different actions. However, I also want the buttons to match the colors of the points on the map. To achieve this, I set the background color in JavaScript when ge ...

Update the image source when hovering over the parent element

Check out this snippet of HTML code: <div class="custom text-center threeBox ofsted"> <a class="ofsted" title="ofsted report" href="http://reports.ofsted.gov.uk/"> <img class="text-center ofstedLogo" src="images/ofsted_good_transparen ...

"Layering text over images using background colors for a unique design touch

Is there a way to create a solid-color overlay that perfectly matches the size of an image using just HTML and CSS? I want to display text on this overlay, but it needs to work with images of any size. The image will be centered and resized to fit within ...

Concealed visual revealed through Javascript within a selected textbox

Is there a way to change the visibility of an image inside a textbox? I would like the placeholder text to become invisible when I select the "search" textbox. Can we achieve the same effect with a picture inside the textbox? Here is the code: <div id ...

Should font size, line height, and font-family be declared to the body before or after the CSS reset?

Let's say I am using the Eric Meyer Reset and I need to apply a style to the body element. body { font: 100%/1.5 "Helvetica Neue", Helvetica, Tahoma, Arial, sans-serif;*/ } Should I place this before or after the reset CSS? html, body, div, span, a ...

Position card action buttons at the bottom using Material UI

I have been working on an app using ReactJS and incorporating MaterialUI (for React) along with React Flexbox. One issue I've encountered is the struggle to position the card buttons at the bottom, which seems to be a common problem across different ...

What is the best way to retrieve the content of a specific class in Selenium WebDriver?

Python Code : from selenium import webdriver from selenium.webdriver.chrome.options import Options options = webdriver.ChromeOptions() options.add_argument(r"--user-data-dir=C:\Users\bji\AppData\Local\Google\Chrome\ ...

Leverage JavaScript to customize the appearance of existing links within an external HTML document

Forgive me for my lack of expertise in Javascript. I will do my best to explain clearly. On my website, I have an external html file for the navigation menu that is loaded with javascript to simplify editing (so I don't need to update nav elements on ...

Can TypeScript be imported into HTML to set a color value or modify a color value from HTML using TypeScript?

I've been working on this code for a couple of days now. Utilizing Angular to develop a web application, I am trying to change the color of certain numbers when they reach a specific value. For example, if num > 45 then color = green, otherwise col ...

Ways to eliminate the yellow highlighting on a row

In my current application, I am incorporating jqGrid and aiming to apply custom styling to it. To start, my objective is to eliminate the yellow highlighting effect that appears when clicking on a row in the jqGrid css. Despite my attempts, I have been u ...

Browse through different backgrounds while a single background remains still for multiple scroll actions

I am trying to create a specific scrolling effect on my webpage: Upon loading the page, I want a div with background1.png to be displayed. As the user starts scrolling, I want this div to remain fixed for a predetermined amount of scroll movements. Once t ...

Guide on creating a div container that spans the full width of the HTML page with a horizontal scrollbar

I'm facing an issue where the div container is not extending over the entire HTML page with a horizontal scroll bar. Here's a visual representation of my problem: Image Despite using MathJax to display math formulas, the div container does not ...

Tips for creating a website with an integrated, easy-to-use editing tool

Recently, I designed a website for a friend who isn't well-versed in HTML/CSS/JavaScript. He specifically requested that the site be custom made instead of using a web creator. Now, he needs to have the ability to make changes to the site without nee ...

Unable to create a border that spans from left to right

Struggling to create a border around icons on my website from left to right. Here's what I'm aiming for: However, the CSS code I have been using doesn't seem to be working properly. This is the outcome I am getting. Any assistance in figur ...