help me figure out why it’s not working properly. I have a react.js component with html tags:
import React, { useEffect, useState, useRef } from "react";
import { useParams } from "react-router-dom";
export default function Subjectlist() {return (
<>
<section className="main-container">
<div className="tab-nav-bar">
<div className="tab-navigation">
<i
className="uil uil-angle-left left-btn"
></i>
<i
className="uil uil-angle-right right-btn"></i>
<ul className="tab-nav-list" ref={tabNavListRef}>
{subjects.map((subject) => (
<li
className="tab-nav-item tab-nav-item-active"
key={subject.id}
>
{subject.subjectName}
</li>
))}
</ul>
</div>
</div>
<div className="tab-subject-content">
<div className="tab-subject _active-tab">
<div className="left-column">
<div className="tab-row">
<div className="img-card">
{subjects.map((subject) => (
<img
className="tab-img"
src={`${subject.img}`}
alt={`${subject.subjectName}`}
key={subject.id}
/>
))}
</div>
<div className="tab-right-column">
<div className="tab-info">
<ion-icon
class="tab-info-icon"
name="arrow-redo-outline"
></ion-icon>
<ion-icon
class="tab-info-icon"
name="chatbubble-ellipses-outline"
></ion-icon>
<ion-icon class="tab-info-icon" name="heart-outline"></ion-icon>
</div>
</div>
</div>
</div>
</div>
</div>
</section>
</>
);
}
I wrote styles for them:
section {
position: relative;
margin: 0 auto;
}
.main-container {
position: relative;
}
.tab-nav-bar {
position: relative;
margin: 65px 10px 40px 10px;
top: 100px;
z-index: 2;
}
.tab-navigation {
max-width: fit-content;
position: relative;
display: flex;
justify-content: center;
align-items: center;
margin: 0 auto;
height: 80px;
}
.tab-nav-list {
list-style-type: none;
max-width: 800px;
background-color: #434354;
border-radius: 50px;
padding: 10px;
border-bottom: 1px solid #434354;
box-shadow: 0 8px 32px rgba(45, 119, 124, 0.37);
white-space: nowrap;
overflow-x: auto;
user-select: none;
scroll-behavior: smooth;
}
.tab-nav-list::-webkit-scrollbar {
display: none;
}
.tab-nav-list .tab-nav-item {
display: inline-block;
margin-right: 10px;
color: #fff;
font-size: 1.2rem;
font-weight: bold;
text-transform: uppercase;
padding: 15px;
border-radius: 50px;
cursor: pointer;
transition: 0.4s ease;
}
.tab-nav-item:hover {
background-color: #2e2e41;
}
.left-btn,
.right-btn {
position: absolute;
color: #fff;
font-size: 2rem;
cursor: pointer;
padding: 20px;
}
.left-btn {
left: 0;
background: linear-gradient(to left, transparent, #2e2e41);
border-top-left-radius: 30px;
border-bottom-left-radius: 30px;
}
.right-btn {
right: 0;
background: linear-gradient(to right, transparent, #2e2e41);
border-top-right-radius: 30px;
border-bottom-right-radius: 30px;
}
.tab-subject-content {
position: relative;
display: flex;
justify-content: center;
}
.tab-subject {
position: absolute;
top: 50px;
right: auto;
bottom: 0;
left: auto;
max-width: 1200px;
padding: 15px 50px;
content-visibility: hidden;
transform: translateX(25px);
opacity: 0;
}
.tab-subject._active-tab {
transform: translateX(0);
content-visibility: visible;
opacity: 1;
transition: 1s ease;
}
.tab-row {
width: 100%;
display: flex;
justify-content: center;
align-items: center;
margin: 50px 0;
gap: 30px;
}
.tab-subject .img-card {
position: relative;
width: auto;
max-width: 800px;
display: flex;
justify-content: center;
align-items: center;
border-radius: 20px;
overflow: hidden;
}
.tab-subject .img-card img {
width: 100%;
background-size: cover;
background-position: 50% 50%;
border-radius: 20px;
}
.tab-right-column {
max-width: 800px;
}
.tab-info {
position: relative;
display: flex;
flex-direction: column;
align-items: space-between;
left: 30px;
}
.tab-info-icon {
width: 35px;
height: 35px;
color: #fff;
margin-bottom: 30px;
cursor: pointer;
}
@media (max-width: 1050px) {
.main-containe {
margin: 0px 0px;
}
.tab-nav-bar {
margin: 65px 20px 40px 25px;
}
.tab-subject {
padding: 10px 25px;
}
.tab-subject .tab-row {
flex-direction: column;
}
.tab-info {
flex-direction: row;
left: 0;
text-align: center;
}
.tab-info-icon {
margin-right: 30px;
}
.tab-subject .img-card {
width: auto;
max-width: 600px;
}
}
but the page does not display the img correctly. It either shows two pictures at once, or one picture and two incomplete ones on the sides: I have attached screenshots
enter image description here
enter image description here
I searched for answers on the Internet but couldn’t find them.