为什么我不能在VS代码/React中使用Bootstrap代码?
嗨,我试图在我的VS Studio项目中使用此代码,我无法弄清楚如何显示它。我知道这是一个自举代码,基本上是CSS代码。那么,我可以将此代码保存为card.css类吗?然后如何在代码中显示它? 尤其是我想使其响应迅速(单击时更改边框颜色以标记为选定)。
<div class="card" style="width: 18rem;">
<img class="card-img-top" src="..." alt="Card image cap">
<div class="card-body">
<h5 class="card-title">Card title</h5>
<p class="card-text">Some quick example text to build on the card title and make up the bulk of the card's content.</p>
<a href="#" class="btn btn-primary">Go somewhere</a>
</div>
</div>
}
我是前端的新手,我正在进行一门Udemy课程以了解更多信息,但仍会提出解释。
太感谢了
Hi im trying to use this code in my VS Studio project and i cant figure out how to display it. I know it is a Bootstrap Code which is basically a CSS Code. So can i just save this code as a Card.css class? And how do i display it then in my Code?
Especially as i want to make it responsive (change border colour on click to mark as selected).
<div class="card" style="width: 18rem;">
<img class="card-img-top" src="..." alt="Card image cap">
<div class="card-body">
<h5 class="card-title">Card title</h5>
<p class="card-text">Some quick example text to build on the card title and make up the bulk of the card's content.</p>
<a href="#" class="btn btn-primary">Go somewhere</a>
</div>
</div>
}
Im new to front end and im doing a an udemy course to learn more but would still aprecciate an explanation.
Thank you so much
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您应该在React中使用
className
,而不是class
您可以在此处检查 https://reactjs.org/docs/faq-styling.html而且,如果您想使用内联样式,它看起来像
stye = {{width:'18rem'}}
You should use
className
in react instead ofclass
you can check it here https://reactjs.org/docs/faq-styling.htmland also if you want to use inline style it would look like this
stye={{width: '18rem'}}
如果要使用Bootstrap进行样式组件,则需要将Bootstrap模块导入项目。
package.json
然后您可以在组件中使用bootstrap类名称。
testcomponent.js
If you want to use bootstrap for styling components, you need to import bootstrap module into your project.
package.json
Then you can use bootstrap class names in your component.
TestComponent.js
在react.js中,使用
className
而不是class
。但是,仍然不建议在React中使用Bootstrap.js。In React.js, use
className
instead ofclass
. But using Bootstrap.js in React is still not recommended.