The elements refuse to shift into their designated grid areas, although a few of them comply

https://i.sstatic.net/z2yC7.png Here is a visual representation of my current grid layout. I successfully changed the position of the picture with the pfp-div class, but I am encountering issues changing the text position with the profile-p-name-div class (I want to move nested DIV containers within a larger DIV container). All smaller div containers have a distinct red border for visibility, while the largest DIV container has a blue border.

Here's an excerpt of my CSS code:

.profile-preview-div {
  display: inline-block;
  border-color: blue;
  border-style: solid;
  border-radius: 20px;
  display: grid;
  grid-template-columns: 20% 40% 40%;
  grid-template-rows: repeat(3, 40px);
  width: 200px;
  zoom: 2;
}

.pfp-div {
  border-color: red;
  border-style: solid;
  border-radius: 5px;
  width: 35px;
  height: 39px;
  margin: 0;
  grid-column: 1 / 2;
  grid-row: 2 / 3;
}

/* Other CSS classes... */

.profile-p-info {
  border-color: red;
  border-style: solid;
  border-radius: 5px;
  width: 80%;
}
<!doctype html>

<html>

<head>
  <title>
    Updated Layout
  </title>
  <script src="java.js"></script>
  <link rel="stylesheet" href="style.css">
</head>

<body>
  <div class="profile-preview-div">
    <div class="pfp-div">
      <img src="/pfps/pic1.png" class="pfp-preview">
    </div>
    <div class="profile-p-info">
      <div class="profile-p-name-div">
        <p class="profile-p-name">asd_adventure</p>
      </div>
      <div class="profile-p-desc-div">
        <p class="profile-p-desc">i really like pizza lol</p>
      </div>
      <div class="profile-p-stats-div">
        <p class="profile-p-stats">Followers: 40</p>
        <p class="profile-p-stats">Following: 30</p>
      </div>
    </div>
    <script>
    </script>
</body>
</html>

Despite my attempts to center the text, it doesn't seem to be working as intended. The image positioning was successful, so I'm unsure what the issue could be with the text alignment.

Answer №1

<div class="profile-preview-div">
  <div class="pfp-div"/>

  <div class="profile-p-info">
    <div class="profile-p-name-div">

.profile-p-name-div is unable to be directly positioned within the grid structure.

To address this, you may consider implementing subgrid on .profile-p-info, although full browser support is not yet universal.

In the meantime, it may be best to extract the contents of .profile-p-info.

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

Is there a way to freeze a row in Bootstrap 4?

I recently put together a slider featuring four images, but I've encountered an issue. When the pixel size drops below 768px, the image quality diminishes and they start stacking on top of each other. Is there a way to keep the images in a single row ...

What is the best method for retrieving text from the aria-label attribute?

Currently, I am delving into the world of web scraping. My goal is to extract the work-life balance rating from the Indeed website. However, the main obstacle I'm encountering is the extraction of text from the aria-label attribute so that I can retri ...

Hover Effect: Inner Border Style Applied to Image Using CSS

I've been on the hunt for a straightforward hover effect to use on images in a gallery. I'm looking for something simple that will add a slight 10px width, 40% transparency to the images. While many tutorials show how to achieve this effect on a ...

Is it necessary to install only form control styles from Bootstrap 4?

Does Bootstrap 4 offer a way to only install the form control styles like input group? I came across a resource that allows you to solely install the Bootstrap 4 Grid. Is there anything similar for downloading just the form styles? ...

Retrieving the country code using Google Maps in conjunction with HTML 5 GeoLocation

I've been working on a project that involves using HTML 5 GeoLocation to retrieve longitude and latitude coordinates, and then utilizing the Google Maps API to obtain the corresponding country code based on those coordinates. However, I seem to be enc ...

The sidebar scrolling feature seems to be malfunctioning, as only the page scrolling functionality is currently

I'm currently working on a webpage that features a sidebar, along with other elements as shown below: https://i.sstatic.net/gf7dX.png In this design, the Your Friends section represents the sidebar. However, I have noticed that when I hover over the ...

Tips for organizing and securing downloaded zip files from external websites

I am currently developing an application using CodeIgniter framework. I have a requirement to only download files with a .zip extension and upload them to my local drive. In order to achieve this, I have been provided with a function called get_zip_content ...

Customizing the appearance of an input button in Internet Explorer 8

I've been trying to style my file input section using a method similar to the one outlined in this article: . However, I'm encountering issues specifically with compatibility in IE8; all I can see is the corner of an oversized button. Here' ...

Exploring Ember Octane (version 3.22 and above): benefits of using {{on 'click' this.function}} over traditional onclick={{this.function}} method

When working with Ember Octane, there are two different ways to attach a function to an event in an hbs file. The first way is the EmberJS approach: {{on 'click' this.function}} Alternatively, you can use the classic HTML method: onclick={{this ...

Deleting a particular tag with regular expressions: a step-by-step guide

I'm attempting to remove a ul tag along with any nested tags inside it. <ul class="related"> <li><a href="/related-1.html" target="_blank">Related article</a></li> <li><a href="/related-2.html" target="_blank"&g ...

`Balance in structure`

Having trouble with CSS. I would like to make this form symmetrical. Buttons should be in one column, textfields in another, and the question mark should also have its own column. Apologies if the ticket structure is not perfect, this is only my second on ...

Transforming bootstrap 4 rows into cards or a card deck

Having some difficulty configuring Bootstrap cards to display correctly. The original template had one item per row in columns, but I want to transform it into polaroid-style cards while still using Bootstrap 4 for a clean look. Original template (excerpt ...

What is the best way to trigger an onclick event for an input element with a type of "image"?

In the code I'm working on, there's an input of type "Image". <div class="icon" id="button_dictionary"> <form> <input class="buttonDictionary" type="image" src="icone_dicionario.jpg" value="" id="inputDictionary"> ...

Unable to Change Color of Buttons in Jquery Mobile

Utilizing JQuery mobile for my application. <input data-mini="true" data-inline="true" data-theme="d" value="Login" type="submit" /> When clicking the button in iOS, the color does not change immediately. It only changes when the button is held for ...

Altering the DOM directly within the componentDidMount() lifecycle method without needing to use

In ReactJS, I am facing an issue while trying to manipulate the DOM in the componentDidMount() method. The problem lies in the fact that the DOM is not fully rendered at this point, requiring me to use a setTimeout function, which I find undesirable. Upon ...

Modifying the value of the onclick function when a button is clicked

I've been searching for a solution to this problem, but haven't found one that fits my specific needs. Currently, my website features a button with the following code: <input class="btn btn-success" onclick="w.start()" type="button" value="S ...

Is it possible for me to store the location of an element in the page_source using the .any? method and assign it to a variable for future reference in my Ruby code

My code is scanning the page source for certain constants like ' AA1 ', ' AA2 ', ' AB3 ', and so on. When a constant is found, I want to be able to access the element next to it, which has a dynamic location and changes freque ...

Experiencing an unexpected issue with Firefox? Seeing unexplained strokes on an image that are not present on other browsers

Currently, I am working on customizing a file input to display its content using a preview <img> tag. <div id="image_preview"> <input> ..... <img id="preview" src="" class="img-fluid" alt=""> </div> While it displa ...

Tips for creating the Next.js Image component to simulate the behavior of a standard <img> tag

I have been grappling with this issue for hours and I'm at a loss for what to do next. Here is how my Image component is wrapped: <div className={styles.featureImgContainer}> <Image src={ post.feature_image } alt={post.ti ...

Looping through JavaScript to generate HTML code

I have come across a HTML code snippet that looks like this: <div class="content"> <article class="underline"> <a href="incidente.html"><img id="incidente" src="img/buraco.jpg" alt="Incidente" /></a> ...