1
我有一個組件,其中有兩個元素傳遞給它。我希望兩個元素並排顯示。我試過在CSS中使用display:inline-block,但實際上並不會將這兩個元素並排放置。我希望元素的大小相同,因此每個元素都將佔用屏幕的50%。在反應中使用組件中的2個元素使用嵌入塊
我覺得CSS的風格有點棘手。任何建議如何使這項工作? 這是我的組件。
class Dashboardbox extends React.Component {
render(){
return(
<div className="dashboardbox">
<Coursebox />
<Newsbox />
</div>
);
}
}
ReactDOM.render(< Dashboardbox />, document.getElementById('dashboardbox'));
和我的CSS
.course {
background-color: lightgrey;
margin-left: 20px;
height: 80%;
border-radius: 10px;
font-family: arial;
padding: 5px 10px 10px 10px;
margin-top: 10px;
}
.dashboard {
display: inline-block;
}
這些css類在哪裏被使用?你對dashboardbox有一個css規則嗎? – ajmajmajma