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

How to update an object property in React using checkboxes

I am currently navigating the world of react and have encountered a challenging issue. I am in the process of developing an ordering application where users can customize their orders by selecting different ingredients. My approach involves using checkboxe ...

Problem with incorporating responsive gifs

I'm new to CSS and I'm trying to incorporate an animated GIF as a smartphone screen using Bootstrap to ensure responsiveness. I've managed to get it working for larger and medium screens, but the issue arises when resizing for smaller displa ...

Encountering an issue with React and Vercel: Why is the command "npm run build" exiting with code 1?

I've been encountering an issue while trying to deploy a simple create-react-app on Vercel. The build log keeps showing the error mentioned in the title. Does anyone have a solution for this? I recently forked and cloned two repositories - one contain ...

Ways to attach jQuery live to the entire window?

tag: I want to trigger specific functions whenever the mouse moves, regardless of its position on the browser window. Currently, I am using the following code snippet: $('html').on('mousemove', function(e) { ... } However, this appr ...

Issue with Bootstrap NavBar collapsing properly on first element

I'm currently working on developing a responsive navbar. Everything seems to be functioning well in larger window sizes, but when I view it on an xs screen, the first element of the navbar does not collapse properly. For reference, here are two exampl ...

Hover state remains persistent even after modal window is activated in outouchend

One of the buttons on my website has a hover effect that changes its opacity. This button is used to share information on Facebook. It's a simple feature to implement. Here is the CSS code: .social_vk, .social_fb { height: 38px; obj ...

How can you achieve three layers of nested quotes in Dynamic HTML?

Working on an app that utilizes JQuery and JQTouch for iOS. The issue I'm facing involves dynamically generated HTML lists where the user clicks a row that needs to be highlighted. However, achieving this has proven tricky due to nesting 3 sets of quo ...

Editing text on an Android device - Removing formatting pieces

I've encountered an issue where trying to remove spans from an EditText using EditText.getText().clearSpans() results in strange behavior. Line feeds start appearing as boxes and any newly set spans are misplaced. My question is: Is there a way to cl ...

Prestashop 1.7 - Enhanced top menu navigation with drop-down subcategories

While using the ps_mainmenu top menu with the default Prestashop theme, I noticed that the drop-down menu only works for parent categories and not subcategories. You can see this in the attached image and HTML code from Chrome. I'm looking for a way t ...

The final condition of the ternary operator fails to render if the specified condition is satisfied

Having trouble identifying the issue with this ternary statement. The last element (blurredscreen) is not appearing when authStatus !== "authenticated". return ( <> <div key={"key-" + id}> {isO ...

Reverting a concealed segment

Can anyone make sense of my unconventional explanation? I've set up a hidden section as shown below: <section class="intro"> <label> <input type="checkbox"> <span class="menu"> <span class="hamburger"></span&g ...

The issue with the Material UI Drawer component is that it is casting a shadow even when

Having some trouble with the Material UI Drawer component. Whenever I try to display it on my webpage, it automatically focuses on the inner div, adding a shadow or border if the focus is anywhere else. Does anyone know why this shadow appears and how to r ...

How can I customize the appearance of the container and items in a dropdown <select> menu?

Im using contact form 7 on wordpress, i don't want to use a plugin rather use plain css/js to bring the results if possible. Something like this : https://i.stack.imgur.com/VTWRg.jpg ...

JSX conditionally rendering with an inline question: <option disabled value="">Select an option</option>

Yes, I can confirm that the inline is functioning properly because in the Convert HK to Passive Segment paragraph at the top I am seeing the expected output. What I am aiming for is to display a "Choose a hotel" message when there are multiple hotels in th ...

The utilization of TypeScript featuring a variable that goes by two different names

As I dive into TypeScript code, coming from a Java background, I struggle to grasp the syntax used in this particular example. The snippet of code in question is extracted from the initial Material UI Select sample: const [labelWidth, setLabelWidth] = Rea ...

To ensure proper formatting, I must include a comma operator for numbers while typing and limit the decimal places to two

Could someone assist me in formatting a number to include commas and restrict the decimal places to two using regex? I have attempted the following, but need help making it work properly. Currently, when I enter a number it shows up as 1231244, however I ...

Modifying an object's label based on a particular value using JavaScript

In my current project involving React.js charts, I am looking to organize data by month. In Django, I have set up a view to display JSON containing the total events per month in the following format: [ { "month": "2022-06-01T00:00:0 ...

Encountering an issue with React Native where initializing a project with npx leads to a "

Running the command: npx react-native init MyApp An error occurred while downloading and copying the template. Error message: Cannot find module 'C:\Users\%%%%\AppData\Local\Temp\rncli-init-template-rVvcjE\node_ ...

Removing HTML tags from a string while preserving specific tags in JavaScript

Here is a JavaScript string that I am working with: var test = "<p>test</p> FOLER.PRODUCTS<12345><level-2>"; I'm trying to remove the HTML tags from the string because the service I'm using doesn't accept them. Here ...

How to limit character input in a Div using Angular 2

I need some guidance on Angular 2 with TypeScript. I want to apply a validation rule to a "Div" element where the maximum length should be set to 100 characters. Additionally, even when text is copied and pasted into the Div, it should not exceed 100 chara ...