Bootstrap 5 Class "col-md-4 " Is Not Working - Stack Overflow

    1. Home
    2. Questions
    3. Tags
    4. Users
    5. Companies
    6. Labs
    7. Jobs
    8. Discussions
    9. Collectives
    10. Communities for your favorite technologies. Explore all Collectives

  1. Teams

    Ask questions, find answers and collaborate at work with Stack Overflow for Teams.

    Try Teams for free Explore Teams
  2. Teams
  3. Ask questions, find answers and collaborate at work with Stack Overflow for Teams. Explore Teams

Collectives™ on Stack Overflow

Find centralized, trusted content and collaborate around the technologies you use most.

Learn more about Collectives

Teams

Q&A for work

Connect and share knowledge within a single location that is structured and easy to search.

Learn more about Teams

Get early access and see previews of new features.

Learn more about Labs Bootstrap 5 class "col-md-4 " is not working Ask Question Asked 3 years, 4 months ago Modified 3 years, 4 months ago Viewed 849 times 3

I want to make a grid of 3 columns and 2 rows using Bootstrap cards but the Grid is not working. All the cards are centered and one after the other. Please help me resolve this.

Service.jsx

const Service =() =>{ return( <div> <div className="my-5"> <h1 className="text-center">Our Services</h1> </div> <div className="container-fluid mb-5"> <div className="row"> <div className="col-10 mx-auto"> <div className="row gy-3"> {Sdata.map((val, ind) => { return( <Card key={ind} imgsrc={val.imgsrc} title={val.title} /> )})} </div> </div> </div> </div> </div> ); };

Card.jsx

const Card =(props) =>{ return( <div> <div className="col-md-4 col-10 mx-auto"> <div className="card"> <img src={props.imgsrc} className="card-img-top" alt={props.imgsrc} /> <div className="card-body"> <h5 className="card-title font-weight-bold">{props.title}</h5> <p className="card-text">Some quick example text to build on the card title and make up the bulk of the card's content.</p> <NavLink to="#" className="btn btn-primary">Go somewhere</NavLink> </div> </div> </div> </div> ); }; Share Improve this question Follow edited Jul 15, 2021 at 12:24 Carol Skelly's user avatar Carol Skelly 361k91 gold badges732 silver badges644 bronze badges asked Jul 15, 2021 at 12:03 Bhavik Jain's user avatar Bhavik JainBhavik Jain 4510 bronze badges 1
  • For Bootstrap 5 you just need to use col-5 – Crezzur Commented Jul 15, 2021 at 12:05
Add a comment |

1 Answer 1

Sorted by: Reset to default Highest score (default) Trending (recent votes count more) Date modified (newest first) Date created (oldest first) 2

"All the cards are centered and one after the other".

The columns are being wrapped by an outer div. Columns must be directly in the parent .row. Remove the outer div.

const Card =(props) =>{ return( <div className="col-md-4 col-10 mx-auto"> <div className="card"> <img src={props.imgsrc} className="card-img-top" alt={props.imgsrc} /> <div className="card-body"> <h5 className="card-title font-weight-bold">{props.title}</h5> <p className="card-text">Some quick example text to build on the card title and make up the bulk of the card's content.</p> <NavLink to="#" className="btn btn-primary">Go somewhere</NavLink> </div> </div> </div> ); };

React demo on Codeply

Share Improve this answer Follow edited Jul 15, 2021 at 12:23 answered Jul 15, 2021 at 12:07 Carol Skelly's user avatar Carol SkellyCarol Skelly 361k91 gold badges732 silver badges644 bronze badges 0 Add a comment |

Your Answer

Reminder: Answers generated by artificial intelligence tools are not allowed on Stack Overflow. Learn more

Thanks for contributing an answer to Stack Overflow!

  • Please be sure to answer the question. Provide details and share your research!

But avoid …

  • Asking for help, clarification, or responding to other answers.
  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.

Draft saved Draft discarded

Sign up or log in

Sign up using Google Sign up using Email and Password Submit

Post as a guest

Name Email

Required, but never shown

Post Your Answer Discard

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.

  • The Overflow Blog
  • We'll Be In Touch - A New Podcast From Stack Overflow!
  • The app that fights for your data privacy rights
  • Featured on Meta
  • More network sites to see advertising test
  • We’re (finally!) going to the cloud!
  • Call for testers for an early access release of a Stack Overflow extension...
0 Bootstrap classes are not picked up in React component 4 bootstrap is not working in ReactJS code 3 Col width in React Bootstrap 1 Bootstrap col-md issue 14 Container, Row, Col - in React-Bootstrap not working 0 The col-sm doesn't work when I have a col-md 0 Bootstrap rows/columns not working in React app 0 make react bootstrap column md 0 why bootstrap styling isnt applied on my tables in reactjs 1 Why 'Col' is not working in React bootstrap?

Hot Network Questions

  • What is the correct article before "/s/ sound"?
  • Did Superdana manufacture a 66 AC outlet power strip/surge protector?
  • What should I do with a package that is delivered to my address but the name is wrong?
  • Strange Brackets in String Writing
  • Why the second C in "recyceln" is pronounced [k] instead of [ts]?
  • Sequence and subsequence
  • Chain skipping when pedaling hard
  • Path from plane
  • Will Spirit trade with SAVEQ when it recovers?
  • Is every automorphism of a cone diagonalisable?
  • Darlington-driven PNP vs. MOSFET
  • How to draw this matrix with stairs and submatrices?
  • Selecting point demanding on distance and date with QGIS Expression
  • Moments of a random variable related to uniform distribution on sphere
  • 1980s or 90s space cartoon with a space prince and princess
  • Is the following necessarily true?
  • Does the twin paradox hold in a universe that's empty except for the twins?
  • How can I solve a multi-delay differential equation?
  • Bleeding radiators
  • Did renaissance actors learn their parts by heart?
  • Remove vertical lines from a cell row
  • Superimposed triangles
  • Is there a theorem in metaphysics that basically says, "Biting the bullet will be inevitable in any metaphysical theory?"
  • Does the earliest known use of an "average" occur after the invention of calculus?
more hot questions Question feed Subscribe to RSS Question feed

To subscribe to this RSS feed, copy and paste this URL into your RSS reader.

default

Từ khóa » Html Bootstrap Col-md