![](/img/trans.png)
[英]React Native Elements Line underneath FormInput Component
[英]Displaying React component on same line as other elements
我正在嘗試讓我構建的 React 組件顯示在與其余文本相同的行上,但它始終出現在與其余元素不同的行上。
這是我的 React 代碼:
<div className={styles['top']}>
<span>WHAT PEOPLE ARE SAYING</span>
<div className={`pull-right ${styles['right']}`}>
<span className={`${styles['rating-words']}`}>{ratingWords}</span>
<Rating className={`${styles['overall-stars']}`}
percentage={this.state.overallPercentage}
color={"#00c18a"}
under={"white"}
/>
</div>
</div>
和.scss:
.top {
margin: 30px 0;
font-weight: bold;
.right {
display: inline-block;
flex-direction: row;
}
.rating-words {
text-transform: uppercase;
}
}
最后,一張它的外觀圖片:
“VERY GOOD”和評級星級應該在同一條線上。 知道如何解決這個問題嗎?
如果您在 of.top 中有兩個子元素,這應該可以工作。
.top {
margin: 30px 0;
font-weight: bold;
display: flex;
flex-direction: row;
justify-content: space-between;
.rating-words {
text-transform: uppercase;
}
.right {
}
}
根據@Chad 所說的,我最終讓它與以下內容一起工作,盡管@torkjels 所說的最終在另一個地方工作得更好。
.top {
margin-top: 40px;
margin-bottom: 30px;
font-weight: bold;
.right {
display: inline-flex;
flex-direction: row;
}
.rating-words {
text-transform: uppercase;
margin-right: 10px;
}
.overall-stars {
margin-top: -2px;
}
}
如果您發布了一個有效的 jsfiddle 或 codepen,它會更容易提供幫助。
嘗試給你的overall-stars
class display: inline-block
。 我假設它已經是一個塊元素,這使得它出現在一個新行上。
const top = {
// Other styles
display: 'flex',
flexDirection: 'row',
}
可能有幫助。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.