【发布时间】:2019-10-12 22:14:48
【问题描述】:
编辑:我使用的是 React 而不是 React Native
我正在使用 React 开发一个项目。我的一个按钮继续继承具有特定字体大小的样式:19px,我无法在代码中找到源代码。 我已经多次检查代码,试图找到可以影响按钮的相应 css 代码。 我也尝试更改字体大小,它们都不是 19px - 我的按钮的样式仍然是 19px 。
这是按钮元素,它是我从 chrome Inspect 获得的样式:
<button class="Social-smallFont-6" style="display: block; border: 0px;
border-radius: 3px; box-shadow: rgba(0, 0, 0, 0.5) 0px 1px 2px; color:
rgb(255, 255, 255); cursor: pointer; font-size: 19px; margin: 5px; width:
calc(100% - 10px); overflow: hidden; padding: 0px 10px; user-select: none;
height: 50px; background: rgb(203, 63, 34);"><div style="align-items: center;
display: flex; height: 100%;"><div style="display: flex; justify-content:
center; min-width: 26px;"><svg xmlns="http://www.w3.org/2000/svg"
width="26px" height="26px" fill="#ffffff" viewBox="0 0 50 50"></div><div
style="width: 10px;"></div><div style="text-align: left; width: 100%;">Login
with Google</div></div></button>
有什么想法吗?
【问题讨论】:
-
您是否尝试过使用
!important?在没有看到更多 CSS 的情况下,我们只能开始对这个问题进行假设。也许有人在代码的其他地方设置了font-size: 19px !important;。如果您在更高级别的定义上使用重要,它可能会覆盖前一个。 -
CSS 类 Social-smallFont-6 的定义是什么?
-
您在 react 或 react-native 项目中使用此代码吗?在 react-native 中,您不能使用 dom 元素(div、按钮)和大多数您没有的样式属性!请检查问题并修改
-
@Izbernado 我使用了 !important 并且它有效,谢谢! @Anthony CSS 类 Social-smallFont-6,是我正在尝试使用的样式,我正在使用 Material UI 和更高的组件样式方法:link
const styles = theme => ({ topright: { alignSelf: 'flex-start', marginTop: 0, position: 'absolute', }, smallFont: { fontSize: 12 + 'px !important', width: 30 + 'vh !important', } });
标签: javascript css reactjs react-native