Having trouble adding custom border colors to your Reactjs cards? Let me help you with that!

I am trying to create Reactjs cards, but I'm having trouble with the border-color styling. My goal is to make cards that look like this- Cards similar to this design

As someone who is new to frontend and react, I could really use some assistance.

Check out the overall page cards image here ->

My page's card section and cards

Here are my codes-

The parent Component card container section->

<div className='Cardsection'>
        <button className="left-btn" onClick={leftbtn}><h1>&lt;</h1></button>
        <button className="right-btn" onClick={rightbtn}><h1>&gt;</h1></button>
        
        <div className="cards-container">
            <Mycard name="Project" Projectimg={Project}/>
            <Mycard name="Project" Projectimg={Project}/>
            <Mycard name="Project" Projectimg={Project}/>
            <Mycard name="Project" Projectimg={Project}/>
            <Mycard cardno='5'/>
            <Mycard cardno='6'/>
            <Mycard cardno='7'/>
            <Mycard cardno='8'/>
            <Mycard cardno='9'/>
            <Mycard cardno='10'/>
        </div>
    </div>

cards cotainer css->

.Cardsection{
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    height: 50vh;
    margin-top: 40rem;
    overflow: hidden;
}

.cards-container{
    display: flex;
    align-items: center;
    overflow-x: hidden;
    overflow-y: hidden;
    scroll-behavior: smooth;
    margin-left: 60px;
    margin-right: 60px;
}

.left-btn, .right-btn{
    width: 60px;
    position: absolute;
    border: none;
    background-color: rgba(255, 255, 255, 0);
}

.left-btn{
    right: 0;
}

.right-btn{
    left: 0;
}

.left-btn>h1, .right-btn>h1{
    font-size: 50px;
    font-weight: bold;
    background-color: rgba(0, 0, 0, 0.436);
    border-radius: 50px;
    color: white;
    width: 50px;
    height: 100px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}

child component code->

<div className='cards-shown'>
      <img src={props.Projectimg} alt="#" />
      <p>{props.name}</p>
    </div>

cards styling->

.cards-shown{
    min-width: 250px;
    height: 300px;
    margin-right: 70px;
    background-color: black;
    border-color:red;
    border-width: 10px;
    gap: 20px;
}

.cards-shown>:nth-child(1){
    justify-content: center;
    align-items: center;
    transform: scale(1);
    width: 70%;
}

.cards-shown>:nth-child(2){
    color: white;
    font-family: 'Lucida Sans';
    font-size: 20px;
    top: 0%;
    padding: 0%;
}

I have attempted to style the border color without success. I hope to achieve transparent background for the cards with only the border color visible, creating a true card-like appearance where I can easily add content or images using props.

Answer №1

To apply a border style to an element, use the border-style property.

For example: border-style: solid;

.cards-shown {
  min-width: 250px;
  height: 300px;
  margin-right: 70px;
  background-color: black;
  border-color: red;
  border-width: 10px;
  border-style: solid;
  gap: 20px;
}
<div class='cards-shown'>
  <img src={props.Projectimg} alt="#" />
  <p>{props.name}</p>
</div>

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

Inserting items into arrays in Angular

I've encountered an issue with pushing an object into an array. The array contains objects, and this component is responsible for displaying them: <div class="row" *ngFor="let element of dietList"> {{element.name}} {{ element.weight }} </d ...

The issue of the color CSS rule not being applied to the button element when transitioning from disabled to enabled on browsers like Safari 14+ is a common challenge

There seems to be an issue with frontend form validation code affecting the disabled attribute of a submit button within a form. Two different css rules are applied for the enabled and disabled states, including changes in the text color of the button ele ...

Retrieve information from a database, then display it on a Datatable using a combination of Django and AJAX

Recently, I delved into Django/ajax/datatables and successfully displayed my data using a {%for%} loop. Now, I'm attempting to achieve the same result with ajax calls. My view: def is_ajax(request): return request.META.get('HTTP_X_REQUESTED_ ...

initialize state using shorthand property in class components

I came across some code recently that caught my eye. It appears to be neat and organized, but there are a few things that seem out of the ordinary to me. Why is state = {} declared without a constructor? Additionally, why is load declared without using th ...

Having difficulty rendering images in PHP

I'm having trouble displaying images on my web server using php, and I keep encountering a server 500 error. The issue appears to be related to this line of code: echo "<img src='$row["sourchPath"]'>": while ($row = mysqli_fetch_asso ...

The dreaded glitch in Angular's setInterval function

My goal is to implement polling for a single page and disable it when the user navigates away from that page. However, I encountered an error during the build process when I attempted to set up the polling interval using setInterval: error TS2362: The lef ...

"Oops! The JSON data seems to have an unexpected character at the beginning of line 1 and column 1 when trying to serve

I've been encountering JSON parse errors in my PERN app and I'm struggling to resolve them. The code seems fine when I'm in development mode, but it starts throwing errors when the build is served. Specifically, I'm facing issues with p ...

Start a Draft.js Editor that includes an unordered list feature

I am trying to pre-populate a draft.js editor with an unordered list made from an array of strings. Here is the code I have so far: const content = ContentState.createFromText(input.join('*'), '*') const editorState = EditorState.crea ...

Find numerous terms within a single sentence

I have encountered a challenge while working on my Express backend. I am trying to create a route that filters results based on user input. Here is what I have so far: router.get( "/search", passport.authenticate("jwt", { session: false }), (req, re ...

A React error occurred: Fullpage Class constructor must be called with the 'new' keyword

Help! I'm encountering an error when using the following tag: React TypeError: Class constructor Fullpage cannot be invoked without 'new' Something seems to have gone wrong in line 1438: renderWithHooks node_modules/react-dom/cjs/react-do ...

Unleash the power of a module by exposing it to the global Window object using the dynamic

In my development process, I am utilizing webpack to bundle and manage my TypeScript modules. However, I am facing a challenge where I need certain modules or chunks to be accessible externally. Can anyone guide me on how to achieve this? Additional conte ...

One or multiple web browsers set in the Browserslist of the project

I have recently started working with the Ionic framework and encountered some warnings while setting up my application. Can anyone help me with a solution? [ng] When starting the Ionic application, I received the following warnings: [ng] One or more browse ...

Obtain data attributes using JQuery's click event handler

I'm facing an issue with a div structure setup as follows: <div class='bar'> <div class='contents'> <div class='element' data-big='join'>JOIN ME</div> <div class=& ...

Updating website links in real time with the power of jquery

Is there a way to dynamically change the parameter of a link? For example: Link1 Link2 Link3 By default, their URL is ?item=text, so link1 would be href="?item=link1", etc. But when I click on link1, the URLs of link2 and link3 should change to include ...

Transferring the test picture to the canvas

Currently, I am facing a challenge with testing an AngularJS service that processes ImageData from a canvas for pattern recognition. For this purpose, I want to create a detailed unit test rather than an end-to-end test to gradually build the service. Howe ...

Retrieve data from a Rails controller using Ajax

Seeking assistance and insight for a coding dilemma I'm facing. In my Rails application, I have a controller named get_songs that retrieves a hash of songs belonging to the currently logged-in user. What I'm trying to achieve is to fetch this dat ...

Encountering a malfunction with Django and ajax

Struggling with a basic ajax form issue - receiving an error message init() got an unexpected keyword argument 'cost' Attempting to implement the guide found here: Initially, it worked smoothly with just one field. However, upon adding more fi ...

The issue with the Ajax page content is causing the form to be submitted multiple times, exceeding the number

I have a website where every page is loaded using ajax, including navigating back to previous pages. However, I am facing an issue when submitting a form using ajax post. I tried caching form data with ajax and it works fine except when I navigate back to ...

Angular: Issue with click() event not functioning properly once dynamic HTML is rendered

There are a few HTML elements being loaded from the server side, and an Angular click() event is also included. However, the event is not firing after the elements are rendered. It is understood that the DOM needs to be notified, but this cannot be done. ...

- Utilize bullet points to exhibit keywords within a D3.js div by appending them

I'm looking to showcase the comma-separated values from a JSON file as a list in a mouseover tooltip on each node. Here is my current code snippet: div.append("div") .attr("class", "tooltip") .style("opacity", 1) .html("Node name : " + d.NodeName + ...