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粉5205457532024-04-04 00:33:48
div { outline: 2px dashed blue; display: inline-block; height: 48px; width: 56px; }