【问题标题】:Why reactstrap doesn't have same behavior like bootstrap?为什么 reactstrap 没有像 bootstrap 一样的行为?
【发布时间】:2018-10-11 02:11:48
【问题描述】:

.backgroundImage {
    background: url("page_livraison1.png") , url("Route.png");
    height: 100vh;
    background-position: bottom;
    background-repeat: no-repeat;
}
.verticalNav {
	background-color: #000000BF;
	height:100vh;
}
<div class="verticalNav col-md-3"> </div>
<div class="backgroundImage col-md-9"> </div>

这是我在 bootstrap 中的代码,但是当我想在 react js 和 reactStrap 中做同样的事情时,我没有得到相同的结果...... 这是我的反应代码

import Background from '../img/page_livraison1.png';
import Background1 from '../img/route.png';

const bgImgStyle = {
  background: `url(${Background})`+','+`url(${Background1})`,
  backgroundRepeat: 'no-repeat',
  height:'100vh',
  backgroundPosition: 'bottom',
}
const sideBarStyle = {
  backgroundColor:'#000000BF',
  height:'100vh',
}

export default {sideBarStyle};
export default {bgImgStyle};
<Row>
  <Col lg="3" md="3" sm="5" xs="6"> 
    <SideBar /> 
  </Col>
  <Col lg="9" md="9" sm="7" xs="6"> 
     <BgImg /> 
  </Col>
</Row>

我不明白为什么结果不一样但是我做了完全相同的代码...

【问题讨论】:

  • 你的引导 HTML 是什么?
  • 什么意思?你会说法语吗?
  • 你很幸运,因为它是一个英文网站,我会翻译成英文。 Aurais-tu le HTML de ton fichier bootstrap ?
  • d'accord j'avais bien compris mais je ne vois pas de quel fichier tu parles ? mon html est envoyer c'est 2 div avec 2 Colonne une de 9 et l'autre de 3 c'est tout le bootstrap vient du cdn tandis qu'en react je l'ai installer en Cli npm commande sa répond a ta question ?
  • 翻译:好的,我理解得很好,我只是不明白你说的是哪个文件。我的 HTML 是 2 div 和 2 col(1 of 9 和 1 of 3)。 Bootstrap 来自 CDN,react 是从 npm 安装的。这能回答你的问题吗?

标签: twitter-bootstrap reactjs reactstrap


【解决方案1】:

最后我找到了答案,问题是我有 2 个 Col,而在这 2 个 col 中我有 2 个 div,其样式就像背景图像和高度一样。 当我导入我的组件时,它是这样的。

<div class="col-md-3> 
<div style="background-color:"black"; height:"100vh";> </div>
</div> 
<div class="col-md-9>
<div style="background-image:".png"; height:"100vh";> </div>
</div>

正确的做法是

<div class="col-md-3" style="...."> </div>
<div class="col-md-9" style="...."> </div>

所以最后我认为它是相同的,但是两个带有大小列的 div 或两个带有 div 内部的 div 这些 div 不是一回事,这就是为什么它的行为不同但我不明白但我修复了它像这样。

谢谢

【讨论】:

  • 这正是我昨天要问的 ;) 太好了!
  • 哦,好吧,也许你说的+睡在上面,我明白了哈哈哈,谢谢
猜你喜欢
  • 2019-09-27
  • 2011-04-09
  • 1970-01-01
  • 2014-07-04
  • 1970-01-01
  • 2021-09-16
  • 1970-01-01
  • 1970-01-01
  • 2019-05-03
相关资源
最近更新 更多