I’m currently building an application that tracks jobs and was wondering how to make this component more responsive to page resizing as the tab shrinks or grows. I experimented a lot with the use of relative and absolute positioning and fixed positioning but I don’t think I’m going at it right. I’m using a mac and react js + laravel combo. Heres a pic of what the component looks like in full screen mode: (as i shrink the page the items start to overlap)
REACT CODE
import React, { useState } from "react";
import "../../css/JobDisplay.css";
import { StarIcon, TrashIcon, PencilIcon } from "@heroicons/react/24/outline";
export default function JobDisplay() {
const [isDynamicDivOpen, setIsDynamicDivOpen] = useState(false);
const toggleDynamicDiv = () => {
setIsDynamicDivOpen(!isDynamicDivOpen);
};
return (
<div className="parentdiv" onClick={toggleDynamicDiv}>
<div className="task">
<button className="star">
<StarIcon className="my-icon" />
</button>
<div className="jobtitle">Job title </div>
<div className="Company"> - Company</div>
<button className="link-button">Link</button>
<div className="status-dropdown">
<select className="status-select">
<option value="interested">Interested</option>
<option value="applied">Applied</option>
<option value="interview">Interview</option>
<option value="offer">Offer</option>
<option value="rejected">Rejected</option>
</select>
</div>
{isDynamicDivOpen && (
<div className="dynamic-div">
<span className="date-applied"> 8/16/2023 </span>
<span className="date-applied-label"> Date Applied </span>
<span className="last-followup"> 8/16/2023 </span>
<span className="last-followup-label"> Last Follow Up </span>
<button className="div-buttons">
<TrashIcon className="my-trash" />
<PencilIcon className="my-pencil" />
</button>
</div>
)}
</div>
</div>
);
}
CSS CODE
.parentdiv {
display: flex;
justify-content: flex-start;
align-items: flex-start;
padding-left: 30px;
}
.task {
border: 3px solid #000000;
background-color: #ffffff;
border-radius: 20px;
padding: 10px;
margin: 10px;
display: flex;
height: 50px;
width: 65%;
font-family: "Courier New", Courier, monospace;
font-size: larger;
font-weight: bold;
position: relative;
align-items: center;
}
.star {
background: none;
border: none;
padding: 0;
cursor: pointer;
}
.my-icon {
height: 50px;
padding: 10px;
width: 50px;
color: black;
transition: color 0.3s;
}
.star:hover .my-icon {
color: red;
}
.status-dropdown {
display: flex;
align-items: center;
}
.status-select {
position: absolute;
right: 8%;
padding: 5px 10px;
border: 4px solid #ccc;
border-radius: 5px;
background-color: #6893ff;
color: #ffffff;
cursor: pointer;
font-family: "Lucida Console", "Courier New", monospace;
font-weight: bold;
}
.status-select:hover {
background-color: #8f00ff;
}
.link-button {
position: absolute;
right: 2%;
padding: 5px 10px;
border: 4px solid #ccc;
border-radius: 5px;
background-color: #ff6969;
color: #ffffff;
cursor: pointer;
font-family: "Lucida Console", "Courier New", monospace;
font-weight: bolder;
}
.link-button:hover {
background-color: #8f00ff;
}
.dynamic-div {
border: 3px solid #000000;
background-color: #ffffff;
border-radius: 20px;
top: 100%;
right: 0%;
padding: 10px;
height: 200px;
display: flex;
width: 90%;
font-family: "Courier New", Courier, monospace;
font-weight: bold;
position: absolute;
align-items: center;
}
.date-applied {
position: absolute;
top: 20px;
left: 20px;
background-color: #ffb800;
padding: 5px;
}
.date-applied-label {
position: absolute;
top: 20px;
left: 140px;
padding: 5px;
}
.last-followup {
position: absolute;
top: 20px;
left: 320px;
padding: 5px;
background-color: #bbff9a;
}
.last-followup-label {
position: absolute;
top: 20px;
left: 440px;
padding: 5px;
}
.div-buttons {
background: none;
border: none;
padding: 0;
cursor: pointer;
}
.my-trash {
position: absolute;
right: 4%;
top: 5%;
height: 25px;
padding: 10px;
width: 50px;
color: black;
transition: color 0.3s;
}
.my-trash:hover {
color: red;
}
.my-pencil {
position: absolute;
right: 0%;
top: 5%;
height: 25px;
padding: 10px;
width: 50px;
color: black;
transition: color 0.3s;
}
.my-pencil:hover {
color: red;
}