【发布时间】:2019-10-21 16:52:57
【问题描述】:
所以我在我的 react (CRA) 项目中使用了我在 codepen 上找到的华丽的搜索栏组件。 我已经在默认的 src/index.js 中导入了 css 然后我有我的搜索组件,它由 Search.js 和 Search.module.css 组成。
显然 Bootstrap 样式和 Search 组件样式不能一起使用,当我在 src/index.js 中注释引导文件导入时,Search 组件将正常工作。
那么我怎样才能只在我的搜索组件上覆盖引导程序? 这是 Search.module.css 的 css
@import url("https://fonts.googleapis.com/css?family=Roboto:400,400i,700");
* {
font-family: Roboto, sans-serif;
padding: 0;
margin: 0;
}
.flexbox {
background: linear-gradient(155deg, #cccccc, #e8ecee, #d4d4d4);
width: 100%;
height: 100%;
display: flex;
justify-content: center;
align-items: center;
}
.search {
margin: 20px;
}
.search>h3 {
font-weight: normal;
}
.search>h1,
.search>h3 {
color: white;
margin-bottom: 15px;
text-shadow: 0 1px #eaeff1;
}
.search>div {
display: inline-block;
position: relative;
}
.search>div:after {
content: "";
background: white;
width: 4px;
height: 20px;
position: absolute;
top: 40px;
right: 2px;
transform: rotate(135deg);
box-shadow: 1px 0 #eaeff1;
}
.search>div>input {
color: white;
font-size: 16px;
background: transparent;
width: 25px;
height: 25px;
padding: 10px;
border: solid 3px white;
outline: none;
border-radius: 35px;
box-shadow: 0 1px #eaeff1;
transition: width 0.5s;
}
.search>div>input::placeholder {
color: #5a5a5a;
opacity: 1;
}
.search>div>input::-ms-placeholder {
color: #efefef;
}
.search>div>input::-ms-input-placeholder {
color: #5a5a5a;
}
.search>div>input:focus,
.search>div>input:valid {
width: 250px;
}
【问题讨论】:
-
“很明显 Bootstrap 样式和搜索组件样式不能一起工作” - 为什么很明显?没有显示代码。我们怎么知道什么不起作用?
-
这里是代码。
标签: css reactjs twitter-bootstrap