html中怎样使组件并排排列,用CSS和React排列两个div并排

由于图像显示我有两个组件,我想并排放置。 d8tnZ.png用CSS和React排列两个div并排

我正在使用React和具有协商,前端和食物的组件具有从另一个组件传递的元素。 我该如何设计这种风格,以便每个元素(谈判,前端和食物)彼此分离,但仍然位于同一列,旁边排列着新闻?

我的JS

class Course extends React.Component {

render() {

return (

{this.props.coursename}

{this.props.status} {this.props.progress}

Start exercise

);

}

}

class Welcomebox extends React.Component {

render() {

return

Welcome Naomi

;

}

}

ReactDOM.render(< Welcomebox />, document.getElementById('welcomebox'));

class Coursebox extends React.Component {

render() {

return (

);

}

}

class Newsbox extends React.Component {

render(){

return (

News

);

}

}

class Dashboardbox extends React.Component {

render(){

return(

);

}

}

ReactDOM.render(< Dashboardbox />, document.getElementById('dashboardbox'));

我的CSS

.box-field,

.newsbox {

width: 45%;

background-color: lightgrey;

font-family: arial;

margin-left: 30px;

height: 80%;

padding: 5px 10px 10px 10px;

border-radius: 10px;

display: inline-block;

}

因此,基本上,每个课程元素我想空间(最好设定保证金)之间和我希望新闻组件与Coursebox组件对齐。如果你想场组件之间的风格差异,你可以在调用组件使用道具传递一个类名

2016-09-26

Naomi

+0

你可以用你的'Newsbox'组件和'Coursebox'组件在一个'div'? –

+0

您是否尝试过使用FlexBox? https://css-tricks.com/snippets/css/a-guide-to-flexbox/ –

+0

我已经将它包裹在一个div中。在反应中,您必须这样做才能将多个元素传递给另一个组件。 @AatifBandey –

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值