Is it wise to use position absolute when floating a React JS tag around a component?

I am eager to dive into a challenging project. My goal is to replicate the design shown in the image below using React JS. Initially, I considered using position: absolute and manipulating the positioning of my divs accordingly. However, upon closer inspection, accomplishing this task seems daunting due to the numerous tags needed for responsiveness and the tedious nature of manually adjusting pixel values. I am now seeking advice or perhaps a plugin that can help simplify this process. Feel free to respond with basic colored square-rectangles if it aids in explaining how I can achieve this effect without focusing on the specific design.

Presently, I have the following code structure:

React JS divs:

profile_picture = () => {
return (
  <div className="profilepicturetechstack">
    ...
  </div>
)

}

CSS associated class:

.profilepicturetechstack {
  display: flex;
  ...
}
...
.text-1-3 {
  text-align: left;
  ...
}

If you could offer some guidance or best practices while omitting my code to focus on the main purpose, I would greatly appreciate it. I am feeling a bit overwhelmed. Thank you!

Figma screenshot for reference: https://i.stack.imgur.com/GBMHC.png

Answer №1

Ramesh brought up a crucial point in the comments about the necessity of absolute positioning for the list items enclosing the main div.

  • To ensure that the list items are not impacted by flexbox, create a container div around them with the same width and height dimensions as the home className.
  • Eliminate all flex containers within the classNames of the list items. Instead, utilize position: absolute to utilize right, left, bottom, and top properties. Experiment with different values using percentages or pixels for desired placements. You can find more information on using either pixels or percentages in this article:
  • For responsive resizing, employ media queries. Using the !important property is crucial to prioritize the appropriate value based on screen size. For further details on media queries, refer to https://css-tricks.com/a-complete-guide-to-css-media-queries/

Here's an example of how one of the list items for responsive resizing could be styled:

.frame-1-6 {  
     position: absolute;
     padding: 16px 24px;
     left: -200px; //Over 900px
     bottom: 115%; //Over 900px
     border: 1px solid black;
     width: 200px;
     box-shadow: 0 40px 30px rgba(25, 25, 46, 0.04);
     border-radius: 16px;
     background-color: #ffffff;
 }

 @media screen and (max-width: 900px) {
     .frame-1-6 {
       left: -150px !important; //Under 900px
       bottom: 100% !important; //Under 900px
     }
 }

In the interactive demonstration, I have positioned some of your list items in their respective areas to illustrate the functionality.

Demonstration Link: https://jsfiddle.net/t3qry2oa/286/

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 it acceptable to directly modify the state in React components when utilizing react-redux?

While browsing the internet, I came across various instances where individuals implemented click events by handling them through function calls within their components. These call functions would then directly modify the state using simple techniques like: ...

Out of the blue div, could you lend your assistance?

I have a code that displays 5 random images with corresponding text. My challenge is that I want to separate the text into another div so that I can add another function to it, while still keeping the images random with their corresponding text. <scr ...

The expected result of getInitialProps() is an object, however it returned "undefined" instead

Currently, I am facing an issue where I am attempting to retrieve data from Firebase in my Next.js application using getInitialProps. However, while the data displays in the VS Code terminal along with some errors, when viewing in the browser, a message ap ...

Persistent footer overlaps lower body content

Issue with Sticky Footer in Safari I recently added a sticky footer to my website, but I'm facing problems with it covering the body content on Safari. It works fine on Chrome and Firefox after adding a bottom margin to the body to adjust for the hei ...

The omission of property transmission when invoking a component

I'm currently learning React.js on Udemy through video tutorials, and I've hit a roadblock when trying to pass a property while calling a component. Interestingly, my code matches exactly with the instructor's code in the tutorial video wher ...

Utilizing a JavaScript variable within a jQuery function as an attribute

var image = "path.png"; Is it possible to include the 'image' variable in the jQuery function like this? $('#mapfoto').prepend('<img id="theImg" src="http://path.gr/" + image />'); ...

Is there a way to lock the eye icon in place within the password field using Vue.js?

I added an eye icon to the right side of my password input fields. However, occasionally error messages may pop up on the page to signify issues with the input fields. When these error messages appear below the relevant input field, the position of the eye ...

Issues loading SVG pattern textures with PHP

While experimenting with SVG and PHP codes, I encountered a frustrating issue that has me stumped. I have an SVG image containing some shapes. Using the fill attribute and the def tag, I can easily apply textures to specific shapes using a simple GET var ...

How to replicate a WordPress menu bar

Embarking on my coding journey, I've completed courses in HTML, PHP, CSS, JavaScript, and MySQL. Now, I've decided to dive into hands-on learning by creating a Wordpress child theme. My current challenge is figuring out how to overlay two differ ...

Experience the sleek transparency when black hues grace the interface on iOS 14 and above

When implementing the code snippet below, .packages > .ulWrapper::after { background: linear-gradient( to left, var(--edge-color) 5%, rgba(0, 0, 0, 0) 95% ); /* option 1 - red */ background: linear-gradient( to left, var(--edg ...

Issue with redux causing component to not re-render after state change

I've been encountering an issue where I have to refresh the page every time I try to delete a post. The store updates after the refresh, as confirmed by the React devtools in Chrome. I'm keen to understand why this is happening. For context, I h ...

What is the best way to apply the addClass method to a list element

I've been searching for a solution to this issue for some time now, and while I believed my code was correct, it doesn't appear to be functioning as expected. HTML <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js ...

What is the best way to set the Material UI Mini Variant Drawer to automatically open on larger screens?

I need assistance in modifying the Material UI Mini Variant Drawer code so that the full-sized drawer is initially open on large and extra-large screen sizes, rather than closed. The mini drawer should only appear when the screen size is medium or smaller. ...

Struggling with implementing the use of XMLHttpRequest to transfer a blob data from MySQL to JavaScript

I have a blob stored in my local WAMP64/MySQL server that I need to retrieve and pass to an HTML file using XMLHttpRequest. I know I should set responseType="blob", but I'm not sure how to transfer the blob from PHP to JavaScript in my HTML file. Any ...

Ways to modify the cursor of a disabled ImageButton on an ASP.Net webpage

Within a ListView, I have dynamically generated ImageButtons. If an image does not have a link, I want to make it disabled. In the ItemDataBound event, I attempted the following approach: img.Enabled = False img.DescriptionUrl = "javascript:void(0);" img. ...

Using CSS alone to maintain responsive aspect ratios: A solution to filling container heights

I'm trying to find a way for an inner div to fill the height of its container with a fixed aspect ratio of 1:1. The usual method using padding works great for filling the width, but not so much for the height. Is it possible to achieve this purely wi ...

Is it normal for a Firebase listener to trigger twice when adding date to the database in React?

I've developed a basic chat application. Once the user submits a message, it is stored in the database along with their username. this.ref.child("/chat").update({username: this.state.username, message: this.state.chatMessage}); Subsequently, I ...

Manipulating values in JavaScript using an onclick event in PHP

I am looking to remove the "http" from the URL part of an input link before sending the data. This is my input code that looks like this when clicked: <input style="outline: none;" type="button" onclick="formatText ('link:url');" class="btn ...

Unable to locate a resolution for the error message "Warning: Task "uglify" not found"

Below is the content of my Gruntfile.js: module.exports = function(grunt) { require('load-grunt-tasks')(grunt); grunt.initConfig({ uglify: { start: { files: { 'js/script.min.js': ['js/script.js&a ...

Unusual behavior in ReactJS and HTML5 video player observed

I currently have two React presentation components that include HTML5 video tags. The first component, named Homepage, is as follows: export default class Homepage extends React.Component { render() { return( <div className="Homepage"> ...