How can I put these divs on the same line?
P粉860897943
P粉860897943 2024-04-03 10:34:15
0
1
288

I have a webpage that contains topics and I want to have four topics per row. I placed 4 dummy topics but they are aligned in a column on the left instead of a row like this:

This is the CSS code I used:

.Topic{
  text-align: center;
  width: 20%;
  background-color: #F2EECB;
  margin: 2%;
}

.Topics{
  background-color: red;
  display: grid;
  gridTemplateColumns: auto auto;
}

This is the JSX code I use to render the theme:

function Topics(){

var TopicsList = TopicsDB.map(topic => 
    <div className="Topic" style={divStyles}>
        <h2> {topic.Name} </h2>
    </div>
    )


return <div className="Topics">
        {TopicsList}
        </div>
        }

Among them, Topics is the red parent div, and Topic is each theme.

Tried using different grid displays and column arrangements with no success.

P粉860897943
P粉860897943

reply all(1)
P粉520545753

div {
  outline: 2px dashed blue;
  display: inline-block;
  
  height: 48px;
  width: 56px;
}
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!