【发布时间】:2020-08-27 18:21:24
【问题描述】:
我有一张带有页脚的 div 类卡片:
<div className='card'>
<img src={thumb2} />
<footer>
<p>Beautifull and cozy house for you and familly</p>
<span>$: 1200,00/month</span>
</footer>
</div>
div 类卡片的这个页脚有如下样式:
.card footer {
background-color: #D6E4E3;
display: flex;
flex-direction: column;
align-items: center;
margin: 0;
padding: 0;
}
当我在页面底部使用相同的标签页脚时,这个新标签的样式会影响我的 div 卡内的标签页脚的样式。我能做些什么来避免这种情况发生?怎样才能使用很多标签页脚且样式互不覆盖?
footer {
height: 5%;
display: flex;
justify-content: center;
background-image: linear-gradient(#5665e7, #7083E5);
}
【问题讨论】:
-
您的问题称为specificity,并且通过为
footer使用全局元素选择器,任何footer元素都将继承这些属性。
标签: html css styles frontend footer