背景:
我正在制作一个具有登录组件、注册组件、应用程序组件、食谱组件和 recipe_tile 组件的食谱应用程序。
我有三个 CSS 文件:Registration.CSS、Login.CSS 和 APP.CSS。前两个 css 文件分别用于注册和登录组件。而 APP.CSS 文件用于 app、recipe 和 recipe_tile 组件。
问题:
问题是某些 CSS 选择器,如背景(包含背景图像)显示在每个组件中,尽管相关的 CSS 文件已导入组件。例如,Registration.CSS 是唯一导入注册组件的 CSS 文件。
我知道一个可能的解决方案是在每个组件中使用内联样式,但这可能很乏味且难以阅读。我可以做任何其他可能的解决方案吗?
注册.CSS 文件:
*{
margin: 0
}
body{
font-family: "Open Sans", sans-serif;
top: 0;
left: 0;
background:
linear-gradient(
rgba(0, 0, 0, 0.45),
rgba(0, 0, 0, 0.45)
),
url("https://i.imgur.com/9MDiW6B.jpg") 70% fixed;
background-size: cover;
}
.box{
color:#26a69a;
display: flex;
align-items: center;
flex-direction: column;
justify-content: center;
width: 40%;
height: 600px;
padding: 100px;
background: #ffffff;
margin-left: 30%;
margin-top: 5%;
}
登录.CSS 文件:
.wrap{
font-family: "Open Sans", sans-serif;
top: 0;
left:0;
background:
linear-gradient(
rgba(0, 0, 0, 0.45),
rgba(0, 0, 0, 0.45)
),
url("https://i.imgur.com/9MDiW6B.jpg") 70% fixed;
background-size: cover;
}
.wrap{
color:#26a69a;
display: flex;
align-items: center;
flex-direction: column;
justify-content: center;
width: 40%;
height: 400px;
padding: 100px;
background: #ffffff;
margin-left: 30%;
margin-top: 5%;
}
APP.CSS 文件:
*{
margin-left: 15px;
}
h1{
color:#26a69a
}
.inputs{
margin-left: 400px;
}
.recipe-input{
width: 50%;
}
.button-input{
margin-top: 30px
}
.card{
display: inline-block;
margin: 2px 100px 60px 2px;
text-align: center;
width: 25%;
height: 460px;
}
.card-image{
display: block;
margin-left: -15px;
width: 105%;
height: 250px;
}
.card-reveal{
text-align: left;
}
这是完整的源代码:https ://github.com/SibRaza15/recipe_app/tree/master/src
函数式编程
动漫人物
相关分类